code: def convert_tensor(
      x: Union[
          torch.Tensor,
          collections.Sequence,
          collections.Mapping,
          str,
          bytes,
      ],
      device: Optional[Union[str, torch.device]] = None,
      non_blocking: bool = False,
  ) -> Union[
      torch.Tensor,
      collections.Sequence,
      collections.Mapping,
      str,
      bytes,
  ]:
      """Move tensors to relevant device.
  
      Args:
          x: input tensor or mapping, or sequence of tensors.
          device: device type to move ``x``.
          non_blocking: convert a CPU Tensor with pinned memory to a CUDA Tensor
              asynchronously with respect to the host if possible
      """
  
      def _func(tensor: torch.Tensor) -> torch.Tensor:
          return (
              tensor.to(device=device, non_blocking=non_blocking)
              if device is not None
              else tensor
          )
  
      return apply_to_tensor(x, _func)
  
imports: import collections.abc
  import functools
  import hashlib
  import logging
  import random
  import shutil
  import warnings
  from pathlib import Path
  from typing import Any, Callable, cast, Dict, List, Optional, TextIO, Tuple, Type, TypeVar, Union
  import torch
label_desc: Use image node_id 1 for calling a global function with example usage: convert_tensor(x, device, non_blocking) and returns: apply_to_tensor, unknown