I wrote a dataloader and dataset class that below

```
class Dataset():
def __init__(self, x, y,z,u):
self.x = x+z
self.y = torch.tensor([y] * len(x)+[u] * len(z) )
def __len__(self):
return len(self.x)
def __getitem__(self, i):
return self.x[i],self.y[i]
class DataLoader():
def __init__(self, ds, bs):
self.ds, self.bs = ds, bs
def __iter__(self):
n = len(self.ds)
l = torch.randperm(n)
for i in range(0, n, self.bs):
idxs_l = l[i:i+self.bs]
yield self.ds[idxs_l]
```

And I get this error for `yield self.ds[idxs_l]`

*TypeError Traceback (most recent call last)

in

----> 1 batch = next(iter(dataloader))

in **iter**(self)

7 for i in range(0, n, self.bs):

8 idxs_l = l[i:i+self.bs]

----> 9 yield self.ds[idxs_l]

in **getitem**(self, i)

8 return len(self.x)

9 def **getitem**(self, i):

—> 10 return self.x[i],self.y[i]

TypeError: only integer tensors of a single element can be converted to an index*

What should I do?