@gphilip This did not work .I am still facing the same issue.
I also tried to use .clone() for the parameters,but still it didn’t work.

for epoch in range(10):

    a=net(inputs.float())
    A=list(net.parameters())[-1].clone()
    a=a.float()
    labels=labels.float()
    print(list(net.parameters())[6].grad)
    
  #  print(outputs.shape,labels.squeeze(1).shape)
    loss = criterion(a,labels.squeeze(1))
    print(list(net.parameters())[-1])

    loss.requires_grad=True
    optimizer.zero_grad()
    
    loss.backward()
    
    optimizer.step()
    B=list(net.parameters())[-1].clone()
    print(torch.equal(B.data,A.data))
    print()
print('Finished Training')'

This is the output I am getting.
None
Parameter containing:
tensor([ 0.0768, -0.1130], requires_grad=True)
True

None
Parameter containing:
tensor([ 0.0768, -0.1130], requires_grad=True)
True

None
Parameter containing:
tensor([ 0.0768, -0.1130], requires_grad=True)
True

None
Parameter containing:
tensor([ 0.0768, -0.1130], requires_grad=True)
True

None
Parameter containing:
tensor([ 0.0768, -0.1130], requires_grad=True)
True