code: def copy_to_device(obj, device):
      if torch.is_tensor(obj):
          # Notice:
          # When in no_grad context, requires_gard is False after movement
          ret = obj.to(device).detach()
          ret.requires_grad = obj.requires_grad
          return ret
      elif isinstance(obj, list):
          return [copy_to_device(i, device) for i in obj]
      elif isinstance(obj, tuple):
          return tuple([copy_to_device(v, device) for v in obj])
      elif isinstance(obj, dict):
          return {k: copy_to_device(v, device) for k, v in obj.items()}
      else:
          return obj
  
file_path: ColossalAI/colossalai/legacy/utils/activation_checkpoint.py
imports: import weakref
  import torch
  from torch.utils.checkpoint import check_backward_validity, detach_variable
  from colossalai.legacy.context.random import get_current_mode, get_states, set_mode, set_seed_states, sync_states
  from colossalai.utils.device import autocast, get_current_device
label_desc: Use image node_id 1 for calling a global function with example usage: copy_to_device(obj, device) and returns: ret, unknown, tuple, unknown, obj