in imnet_evaluate/samplers.py [0:0]
def list_collate(batch):
"""
Collate into a list instead of a tensor to deal with variable-sized inputs
"""
elem_type = type(batch[0])
if isinstance(batch[0], torch.Tensor):
return batch
elif elem_type.__module__ == 'numpy':
if elem_type.__name__ == 'ndarray':
return list_collate([torch.from_numpy(b) for b in batch])
elif isinstance(batch[0], Mapping):
return {key: list_collate([d[key] for d in batch]) for key in batch[0]}
elif isinstance(batch[0], Sequence):
transposed = zip(*batch)
return [list_collate(samples) for samples in transposed]
return default_collate(batch)