Solved by takafusui in post #18 
              
              
                Thank you for your comments. After some trials, I finally figured out the way and pass torch.autograd.gradcheck. Just in case, I attach the code below. I appreciate your continuous help. 
import numpy as np
import torch

print(r"PyTorch version is {}".format(torch.__version__))

# ------------------…