Classic Doctor Who
Arc of Infinity: Part 2
S20 E2:
The execution program is mysteriously intercepted and the Doctor's mind is imprisoned in the Matrix as someone tries to bond with the Doctor.