code: def stack(data, device: torch.types.Device = None):
      if isinstance(data[0], np.ndarray):
          data = torch.tensor(np.array(data), device=device)
      elif isinstance(data[0], (list, tuple)):
          return list(stack(t, device=device) for t in zip(*data))
      return data
  
imports: from typing import List
  import numpy
  import torch
  from gluonts.dataset.common import DataBatch
label_desc: Use image node_id 1 for calling a global function with example usage: stack(data, device) and returns: data, list