original_docstring: Moves data to device, or other type, and handles containers.
  
      Very similar to torch.utils.data._utils.pin_memory.pin_memory,
      but applies .to() instead.
      
docstring: Moves data to device, or other type, and handles containers.
docstring_tokens: Moves data to device or other type and handles containers .
code: def recursive_to(data, *args, **kwargs):
      """Moves data to device, or other type, and handles containers.
  
      Very similar to torch.utils.data._utils.pin_memory.pin_memory,
      but applies .to() instead.
      """
      if isinstance(data, torch.Tensor):
          return data.to(*args, **kwargs)
      elif isinstance(data, collections.abc.Mapping):
          return {
              k: recursive_to(sample, *args, **kwargs)
              for k, sample in data.items()
          }
      elif isinstance(data, tuple) and hasattr(data, "_fields"):  # namedtuple
          return type(data)(
              *(recursive_to(sample, *args, **kwargs) for sample in data)
          )
      elif isinstance(data, collections.abc.Sequence):
          return [recursive_to(sample, *args, **kwargs) for sample in data]
      elif hasattr(data, "to"):
          return data.to(*args, **kwargs)
      # What should be done with unknown data?
      # For now, just return as they are
      else:
          return data
code_tokens: def recursive_to ( data , * args , ** kwargs ) : if isinstance ( data , torch . Tensor ) : return data . to ( * args , ** kwargs ) elif isinstance ( data , collections . abc . Mapping ) : return { k : recursive_to ( sample , * args , ** kwargs ) for k , sample in data . items ( ) } elif isinstance ( data , tuple ) and hasattr ( data , "_fields" ) : return type ( data ) ( * ( recursive_to ( sample , * args , ** kwargs ) for sample in data ) ) elif isinstance ( data , collections . abc . Sequence ) : return [ recursive_to ( sample , * args , ** kwargs ) for sample in data ] elif hasattr ( data , "to" ) : return data . to ( * args , ** kwargs ) else : return data
short_docstring: Moves data to device, or other type, and handles containers.
short_docstring_tokens: Moves data to device or other type and handles containers .
comment: """Moves data to device, or other type, and handles containers.
  
      Very similar to torch.utils.data._utils.pin_memory.pin_memory,
      but applies .to() instead.
      """$SEP$# namedtuple$SEP$# What should be done with unknown data?$SEP$# For now, just return as they are