class_docstr: Actor to perform distributed training.
class_docstr_tok: ["Actor","to","perform","distributed","training","."]
docstr: Runs the fairseq training.
  
  We set args for different ray actors for communication,
  add a checkpoint hook, and call the main function of fairseq.
docstr_tok: ["Runs","the","fairseq","training",".","We","set","args","for","different","ray","actors","for","communication",",","add","a","checkpoint","hook",",","and","call","the","main","function","of","fairseq","."]
code: def run(self, url, world_rank, args):
      """Runs the fairseq training.
  
      We set args for different ray actors for communication,
      add a checkpoint hook, and call the main function of fairseq.
      """
  
      # Set the init_method and rank of the process for distributed training.
      print(
          "Ray worker at {url} rank {rank}".format(
              url=url, rank=world_rank
          )
      )
      self.url = url
      self.world_rank = world_rank
      args.distributed_rank = world_rank
      args.distributed_init_method = url
  
      # Add a checkpoint hook to make use of new resources.
      self.add_checkpoint_hook(args)
  
      # Call the original main function of fairseq.
      main(args, init_distributed=(args.distributed_world_size > 1))
  
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 1 for calling the RayDistributedActor obj's underlying member method code with example usage: obj.run(url, world_rank, args) without return types