code: def _set_cuda(
      use_cuda_if_available: bool,
      device_id: int = 0,
      world_size: int = 1,
  ) -> None:
      cuda.CUDA_ENABLED = (
          use_cuda_if_available and torch.cuda.is_available()
      )
      cuda.DISTRIBUTED_WORLD_SIZE = world_size
  
      if use_cuda_if_available and not cuda.CUDA_ENABLED:
          print("Cuda is not available, running on CPU...")
      elif cuda.CUDA_ENABLED:
          torch.cuda.set_device(device_id)
  
      if device_id == 0:
          print(
              """
          # for debug of GPU
          use_cuda_if_available: {}
          device_id: {}
          world_size: {}
          torch.cuda.is_available(): {}
          cuda.CUDA_ENABLED: {}
          cuda.DISTRIBUTED_WORLD_SIZE: {}
          """.format(
                  use_cuda_if_available,
                  device_id,
                  world_size,
                  torch.cuda.is_available(),
                  cuda.CUDA_ENABLED,
                  cuda.DISTRIBUTED_WORLD_SIZE,
              )
          )
  
imports: import gzip
  import json
  import os
  import sys
  import traceback
  from typing import Any, Dict, get_type_hints, IO, Iterator, List, Optional, Tuple, Union
  import torch
  from pytext.common.constants import Stage
  from pytext.config import ExportConfig, PyTextConfig, TestConfig
  from pytext.config.component import ComponentType, create_component, create_exporter
  from pytext.data.data import Batcher
  from pytext.data.data_handler import CommonMetadata
  from pytext.metric_reporters.channel import Channel
  from pytext.task import create_task, get_latest_checkpoint_path, load, NewTask, save, Task_Deprecated
  from pytext.task.disjoint_multitask import NewDisjointMultitask
  from pytext.trainers import TrainingState
  from pytext.utils import cuda, distributed, precision, round_seq, set_random_seeds, timing
  from pytext.utils.file_io import PathManager
label_desc: Use image node_id 1 for calling a global function with example usage: _set_cuda(use_cuda_if_available, device_id, world_size) without return types