code: def _set_cuda_rng_state(new_state, device=-1):
      """Sets the random number generator state of the current GPU.
  
      Arguments:
          new_state (torch.ByteTensor): The desired state
      This function is adapted from PyTorch repo (torch.cuda.set_rng_state) #ignore-cuda
      with a single change: the input state is not cloned. Cloning caused
      major performance issues for +4 GPU cases.
      """
      if hasattr(_C, "_cuda_setRNGState") and callable(
          _C._cuda_setRNGState
      ):
          # older PyTorch
          def cb():
              with get_accelerator().device(device):
                  _C._cuda_setRNGState(new_state)
  
      else:
          # newer PyTorch
          if device == -1:
              device = torch.device(get_accelerator().device_name())
          elif isinstance(device, str):
              device = torch.device(device)
          elif isinstance(device, int):
              device = torch.device(
                  get_accelerator().device_name(), device
              )
  
          def cb():
              idx = device.index
              if idx is None:
                  idx = get_accelerator().current_device()
              default_generator = get_accelerator().default_generator(
                  idx
              )
              default_generator.set_state(new_state)
  
      get_accelerator().lazy_call(cb)
  
imports: import copy
  import torch
  import contextlib
  from deepspeed import comm
  import weakref
  import mmap
  from torch import _C
  from deepspeed.runtime.config import DeepSpeedConfig
  from deepspeed.utils import logger
  from deepspeed.runtime.utils import copy_to_device, move_to_device, see_memory_usage, bwc_tensor_model_parallel_rank
  from deepspeed.utils.timer import SynchronizedWallClockTimer, FORWARD_GLOBAL_TIMER
  from deepspeed.accelerator import get_accelerator
label_desc: Use image node_id 2 for calling a global function with example usage: _set_cuda_rng_state(new_state, device) without return types