.item() returns the value as a “standard Python number”, while the .data attribute accesses the internal tensor with its value (and you could thus easily break the computation graph by manipulating it).
x = torch.randn(1)
print(x.item())
> -0.7826926112174988
print(x.data)
> tensor([-0.7827])