Jus remove Variable and it will work
import torch
def get_torch_G2(Rij, Rs, eta):
    return 0.5 * torch.exp(-eta * (Rij - Rs).pow(2)) * (torch.cos(3.1416 * Rij / 12)+1)
dd = torch.tensor([2.2], requires_grad=True)
bb = get_torch_G2(dd, 0, 1)
bb.backward()
dd.grad.clone()