I don’t know exact location of the source of the error. I am getting the error like
  File "/home/ashishverma/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "/home/ashishverma/Documents/Codes/Eye_traj_pred/mytrain.py", line 182, in <module>
    main(args)

  File "/home/ashishverma/Documents/Codes/Eye_traj_pred/mytrain.py", line 76, in main
    train(train_loader, net, criterion,ll_calculation, optimizer, epoch, train_args)

  File "/home/ashishverma/Documents/Codes/Eye_traj_pred/mytrain.py", line 168, in train
    loss.backward()

  File "/home/ashishverma/anaconda3/lib/python3.6/site-packages/torch/tensor.py", line 93, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)

  File "/home/ashishverma/anaconda3/lib/python3.6/site-packages/torch/autograd/__init__.py", line 89, in backward
    allow_unreachable=True)  # allow_unreachable flag

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation