code: def _to_tensor(sample):
      if isinstance(sample, torch.Tensor):
          return sample
      elif isinstance(sample, numpy.ndarray):
          return torch.from_numpy(sample)
      else:
          return torch.tensor(sample)
  
file_path: nni/nni/contrib/distillation/utils.py
imports: from pathlib import Path
  import pickle
  import random
  from typing import Dict, List
  import numpy
  import torch
label_desc: Use image node_id 1 for calling a global function with example usage: _to_tensor(sample) and returns: sample, torch, torch