Here is a small example to reproduce this error and how to slice the larger tensor:
# Works, since a and b have the same length
a = torch.arange(10).view(-1, 1)
b = torch.arange(10).view(-1, 1)

dataset = TensorDataset(a, b)
loader = DataLoader(
    dataset,
    batch_size=5
)

for idx, (data1, data2) in enumerate(loader):
    print('Idx ', idx)
    print(data1)
    print(data2)

# Use different lengths
a = torch.arange(10).view(-1, 1)
b = torch.arange(20).view(-1, 1)

dataset = TensorDataset(a, b) # fails
# Slice b to have the same length
dataset = TensorDataset(a, b[:a.size(0)])
loader = DataLoader(
    dataset,
    batch_size=5
)

for idx, (data1, data2) in enumerate(loader):
    print('Idx ', idx)
    print(data1)
    print(data2)

Note that this approach might not be the best for your use case, so you should apply your method to yield corresponding pairs of both input tensors.