class_docstr: An example :class:`~flash.core.data.io.input_transform.InputTransform`.
docstr: Transform which converts the sample to a tensor.
docstr_tok: ["Transform","which","converts","the","sample","to","a","tensor","."]
code: 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
  
imports: from typing import Any, Callable, Collection, Dict, List, Optional, Sequence, Tuple, Type
  import numpy
  import torch
  from flash.core.data.base_viz import BaseVisualization
  from flash.core.data.callback import BaseDataFetcher
  from flash.core.data.data_module import DataModule
  from flash.core.data.io.classification_input import ClassificationInputMixin
  from flash.core.data.io.input import DataKeys, Input
  from flash.core.data.io.input_transform import InputTransform
  from flash.core.data.utilities.classification import TargetFormatter
  from flash.core.data.utilities.samples import to_samples
  from flash.core.utilities.imports import _SKLEARN_AVAILABLE
  from flash.core.utilities.stages import RunningStage
  from flash.core.utilities.types import INPUT_TRANSFORM_TYPE
label_desc: Use image node_id 1 for calling the TemplateInputTransform obj's underlying member method code with example usage: obj.to_tensor(sample) and returns: sample