code: def to_tensor(sample: Dict[str, Any]) -> Dict[str, Any]:
      tensor_sample = {}
      for key in sample:
          if key is DataKeys.METADATA:
              tensor_sample[key] = sample[key]
          else:
              tensor_sample[key] = torch.tensor(sample[key])
      return tensor_sample
  
file_path: lightning-flash/src/flash/core/integrations/transformers/collate.py
imports: from dataclasses import dataclass, field
  from typing import Any, Dict, Optional
  import torch
  from flash.core.data.io.input import DataKeys
  from flash.core.utilities.imports import _TRANSFORMERS_AVAILABLE
label_desc: Use image node_id 2 for calling the TransformersCollate obj's underlying member method code with example usage: obj.to_tensor(sample) and returns: tensor_sample