code: def to_device(x: Any, device: torch.device) -> Any:
      def _to(t: Any):
          if isinstance(t, torch.Tensor):
              return t.to(device)
          return t
  
      return tree_map(_to, x)
  
file_path: ColossalAI/applications/Chat/coati/trainer/utils.py
imports: from typing import Any
  import torch
  import torch.distributed
  from torch.utils._pytree import tree_map
  from torch.utils.data import DataLoader
label_desc: Use image node_id 2 for calling a global function with example usage: to_device(x, device) and returns: tree_map, t, t