[fix] PyTorch fix
@@ -545,7 +545,7 @@ class TorchBackend(Backend):
def eval_grad(*args):
args = [self.as_tensor(arg, True) if i in wrt else arg for i, arg in enumerate(args)]
for i, arg in enumerate(args):
- if arg.requires_grad and not arg.is_leaf:
+ if self.is_tensor(arg, True) and arg.requires_grad and not arg.is_leaf:
arg = torch.clone(arg).detach()
arg.requires_grad = True
args[i] = arg
