def allennlp_collate(instances: List[Instance]) -> TensorDict:
    """
    This is the default function used to turn a list of `Instance`s into a `TensorDict`
    batch.
    """
    batch = Batch(instances)
    return batch.as_tensor_dict()
This is the default function used to turn a list of `Instance`s into a `TensorDict`
batch.
allennlp/data/data_loaders/data_collator.py