code: def change_device(var, device):
      if isinstance(var, torch.Tensor):
          if var.device == "cpu":
              var.to(device)
              return var
          elif var.device != device:
              return var.cpu().to(device)
          else:
              return var
      if isinstance(var, dict):
          for key in var.keys():
              if isinstance(var[key], torch.Tensor):
                  var[key] = var[key].to(device)
          return var
  
      return torch.from_numpy(var).float().to(device)
  
imports: import json
  import pickle
  import random
  import torch
  import numpy
  import pandas
  from tqdm.auto import tqdm
  from typing import Iterator
  from gluonts.dataset.common import DataEntry, Dataset, ListDataset
label_desc: Use image node_id 7 for calling a global function with example usage: change_device(var, device) and returns: torch, var, var, var, var