The second error points towards an invalid indexing with a string:
real_A = Variable(batch["A"].type(Tensor))

so apparently batch is not a dict, which can be indexed in this way.
The first error points forwards a missing if-clause protection as explained in the error message and here 21.
Unrelated to this issue, but Variables are deprecated since PyTorch 0.4, so you can use tensors now.
PS: You can post code snippets by wrapping them into three backticks ```, which makes debugging a bit easier.