code: def send_to_device(tensor: Any, device: torch.device):
      """
      Recursively sends the elements in a nested list/tuple/dictionary of tensors to a given device.
      Borrowed from huggingface/accelerate.
      Args:
          tensor (nested list/tuple/dictionary of :obj:`torch.Tensor`):
              The data to send to a given device.
          device (:obj:`torch.device`):
              The device to send the data to
  
      Returns:
          The same data structure as :obj:`tensor` with all tensors sent to the proper device.
      """
  
      def _send_to_device(t, device):
          return t.to(device)
  
      def _has_to_method(t):
          return hasattr(t, "to")
  
      return recursively_apply(
          _send_to_device, tensor, device, test_type=_has_to_method
      )
  
imports: import random
  from typing import NamedTuple, Any, Generator, Callable, Dict, Union
  from collections.abc import Mapping
  from enum import Enum
  import numpy
  import torch
  import os
  from pathlib import Path
  import torch.distributed
  from torch import nn
label_desc: Use image node_id 11 for calling a global function with example usage: send_to_device(tensor, device) and returns: recursively_apply, t, hasattr