code: def to_tensor(array, dtype=torch.float32, device=torch.device("cpu")):
      if "torch.tensor" not in str(type(array)):
          return torch.tensor(array, dtype=dtype).to(device)
      else:
          return array.to(device)
  
imports: from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import division
  import os.path
  import pickle
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 1 for calling a global function with example usage: to_tensor(array, dtype, device) and returns: torch, array