code: def move_to_device(
      opts,
      x: Any,
      device: Optional[str] = "cpu",
      non_blocking: Optional[bool] = True,
      *args,
      **kwargs,
  ) -> Any:
      """Helper function to move data to a device"""
      if isinstance(x, Dict):
          for k, v in x.items():
              x[k] = move_to_device(
                  opts=opts,
                  x=v,
                  device=device,
                  non_blocking=non_blocking,
              )
  
      elif isinstance(x, Tensor):
          # only tensors can be moved to a device
          x = x.to(device=device, non_blocking=non_blocking)
      elif isinstance(x, List):
          x = [move_to_device(opts, a, device, non_blocking) for a in x]
      return x
  
file_path: ml-cvnets/utils/common_utils.py
imports: import os
  import random
  from typing import Any, Dict, List, Optional, Tuple
  import numpy
  import torch
  from packaging import version
  from torch import Tensor
  from common import MIN_TORCH_VERSION
  from utils import logger
  from utils.ddp_utils import is_master
label_desc: Use image node_id 6 for calling a global function with example usage: move_to_device(opts, x, device, non_blocking) and returns: x