labels seems to be a scalar and thus doesn’t have dimensions:
labels = torch.tensor(1.)
print(labels.shape)
> torch.Size([])
labels.size(0)
> IndexError: dimension specified as 0 but tensor has no dimensions

Make sure cond is created as a tensor with the expected number of dimensions.