Hello,
just found my mistake.
The Dataloader works with the len function.I had connected it with the previous dataform. So my problem is solved.
The code should look like the following.
class SpectralDataset(Dataset):
    def __init__(self):
        xy = np.loadtxt(Dataset_Path, delimiter=",", dtype=np.float32)
        # pylint: disable=E1101 # Fehler in VSC muss hier hinzugefügt werden
        x = torch.from_numpy(xy[:, 2:])
        x = torch.reshape(x, (45, 400, 91))
        self.x = x.permute(0, 2, 1)
        self.len = x.shape[0]
        # pylint: enable=E1101 # Fehler in VSC muss hier hinzugefügt werden

    def __getitem__(self, index):
        return self.x[index]

    def __len__(self):
        return self.len
dataset = SpectralDataset()