Yes okay than the first thought was right.
Traceback (most recent call last):
  File "<input>", line 343, in <module>
  File "<input>", line 245, in recallTop
  File "C:\Users\nero-\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\tensor.py", line 630, in __array__
    return self.numpy()
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

(same error as just before i added the x.to y.to mask.to lenghts.to x_val.to y_val.to mask.to lenghts.to)