code: def _move_to_device(x, y, device):
      if isinstance(y, list):
          x = [o.to(device) for o in x]
          y = [
              {
                  k: (
                      v.to(device) if isinstance(v, torch.Tensor) else v
                  )
                  for k, v in o.items()
              }
              for o in y
          ]
      elif isinstance(
          y, dict
      ):  # this covers the efficientdet case in which `y` is a dict of Union[list, tensor] and not a list of dicts and `x` is a Tensor and not a list of Tensors
          # and the mmdet case in which x and y are merged into a single dict, hence x will be None
          x = x.to(device) if x is not None else x
          for k in y.keys():
              if isinstance(y[k], list):
                  y[k] = [
                      o.to(device) if isinstance(o, torch.Tensor) else o
                      for o in y[k]
                  ]
              else:
                  y[k] = (
                      y[k].to(device)
                      if isinstance(y[k], torch.Tensor)
                      else y[k]
                  )
      else:
          return x.to(device), y.to(device)
      return x, y
  
file_path: icevision/icevision/models/interpretation.py
imports: from icevision.imports import *
  from icevision.utils import *
  from icevision.core import *
  from icevision.data import *
  from icevision.visualize.show_data import show_preds
  from icevision.core.record_components import LossesRecordComponent
label_desc: Use image node_id 4 for calling a global function with example usage: _move_to_device(x, y, device) and returns: x,  y, x,  y