def to_tensor(sample: Dict[str, Any]):
        """Transform which converts the sample to a tensor."""
        sample[DataKeys.INPUT] = torch.from_numpy(sample[DataKeys.INPUT]).float()

        if DataKeys.TARGET in sample:
            sample[DataKeys.TARGET] = torch.as_tensor(sample[DataKeys.TARGET]).long()

        return sample
Transform which converts the sample to a tensor.
src/flash/template/classification/data.py