How to fix: "AttributeError: 'numpy.ndarray' object has no attribute 'cpu'"

Hi All I have data from a dataloader which I get a data and corresponding label from it. I am trying to normalize the labels within a certain range using T.tonumpy_denormalize , however I get this error AttributeError: 'numpy.ndarray' object has no attribute 'cpu'. I am not sure how to clear or override this error. Below is my sample code:

val = "./data.txt"
val_data = torch.load(val)
dataloader = torch.utils.data.DataLoader(val_data, batch_size=1, shuffle=True)

def evaluate(model):
      label_min = 1500
      label_max = 4500
      data, label = iter(dataloader).next()
      label_np = T.tonumpy_denormalize(label, label_min, label_max, exp=False)   # I get the error on this line.

# full error message
label_np = T.tonumpy_denormalize(label, label_min, label_max, exp=False)
  File "/home/pi/Desktop/exp/fcnvmb/transforms.py", line 97, in tonumpy_denormalize
    vid = minmax_denormalize(vid.cpu().numpy(), vmin, vmax, scale)
AttributeError: 'numpy.ndarray' object has no attribute 'cpu'

It seems your method expects a PyTorch tensor as it wants to call .cpu() on it while a numpy array is passed, which does not support the .cpu() operation so check and fix your input.