You can’t do this, it’s incompatible with how TensorFlow works. You’ll have to set up the testing operations before the graph is finalized, then fetch the appropriate tensors inside the loop and compute WER metrics on them. It’ll require lots of changes to the training code and good understanding of TensorFlow 1.x semantics.