code: def set_num_resources(args):
      """Get the number of resources and set the corresponding fields."""
      if args.cpu:
          args.distributed_world_size = int(
              ray.cluster_resources()["CPU"]
          )
      else:
          n_gpus = int(ray.cluster_resources().get("GPU", 0))
          while n_gpus == 0:
              print("No GPUs available, wait 10 seconds")
              time.sleep(10)
              n_gpus = int(ray.cluster_resources().get("GPU", 0))
          args.distributed_world_size = n_gpus
  
file_path: ray/doc/source/ray-core/examples/lm/ray_train.py
imports: import copy
  import math
  import socket
  import time
  from contextlib import closing
  import fairseq
  from fairseq import options
  from fairseq_cli.train import main
  import ray
label_desc: Use image node_id 3 for calling a global function with example usage: set_num_resources(args) without return types