@G.M Thanks for the reply. Still the same problem:
  img_inp = torch.tensor(prepare_img(img).transpose(2, 0, 1)[None]).to(dtype=torch.float)
RuntimeError: unsupported operation: more than one element of the written-to tensor refers to a single memory location. Please clone() the tensor before performing the operation.