Thanks for recommendation. I think I get the need for requires_grad=True, but I’m still not sure I understand when. Fr example, the following runs:
def forward(self, x, y):
    return sum(torch.abs(x - y))

But this gives the runtime error:
def forward(self, x, y):
    return sum(torch.abs(x - y) > 0.5)

What is it about the ‘>’ that causes the error?