RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

I think this error happens because of the following line:
training_batch2 = training_batch.clone().detach().cpu().numpy()

You do not compute the gradients of the input (batch) so, it has required_grad=False. See if removing .detach() from that line removes that error?