class_docstr: Assign a unique ordinal rank to each process for distributed training.
  
  torch.distributed requires that N communicating processes register
  themselves with globally unique ranks [0, ..., N-1]. Distributed training
  launches several communicating subprocesses on each machine. This class
  manages the assignment from processes/subprocesses to ranks.
class_docstr_tok: ["Assign","a","unique","ordinal","rank","to","each","process","for","distributed","training",".","torch.distributed","requires","that","N","communicating","processes","register","themselves","with","globally","unique","ranks","[","0",",","...",",","N-1","]",".","Distributed","training","launches","several","communicating","subprocesses","on","each","machine",".","This","class","manages","the","assignment","from","processes\/subprocesses","to","ranks","."]
code: def from_num_invocations(
      cls, num_machines: int, num_partition_servers: int
  ) -> "ProcessRanks":
      world_size = 0
  
      def add_group(group_size: int) -> List[Rank]:
          nonlocal world_size
          group = [world_size + r for r in range(group_size)]
          world_size += group_size
          return group
  
      trainers = add_group(num_machines)
      parameter_servers = add_group(num_machines)
      parameter_clients = add_group(num_machines)
      (lock_server,) = add_group(1)
      if num_partition_servers < 0:
          # Use machines as partition servers
          partition_servers = add_group(num_machines)
      else:
          partition_servers = add_group(num_partition_servers)
  
      return cls(
          world_size,
          trainers,
          parameter_servers,
          parameter_clients,
          lock_server,
          partition_servers,
      )
  
file_path: PyTorch-BigGraph/torchbiggraph/distributed.py
imports: import logging
  import multiprocessing
  import os
  from abc import ABC, abstractmethod
  from datetime import timedelta
  from typing import Callable, List, NamedTuple, Optional
  import torch.distributed
  import torch.multiprocessing
  from torchbiggraph.types import Rank
  from torchbiggraph.util import tag_logs_with_process_name
label_desc: Use image node_id 1 for calling the ProcessRanks obj's underlying member method code with example usage: obj.from_num_invocations(cls, num_machines, num_partition_servers) and returns: cls, group