class_docstr: Wrapper class for the basic Horovod API.
docstr: Add a new process set and return its id. If a process set containing the same ranks exists already, return
   None.
  
  Requires running with HOROVOD_DYNAMIC_PROCESS_SETS=1.
docstr_tok: ["Add","a","new","process","set","and","return","its","id",".","If","a","process","set","containing","the","same","ranks","exists","already",",","return","None",".","Requires","running","with","HOROVOD_DYNAMIC_PROCESS_SETS=1","."]
code: def _add_process_set_impl(
      self, ranks: Sequence[int]
  ) -> Optional[int]:
      """Add a new process set and return its id. If a process set containing the same ranks exists already, return
       None.
  
      Requires running with HOROVOD_DYNAMIC_PROCESS_SETS=1.
      """
      if not isinstance(ranks, list):
          ranks = list(ranks)
      nrank = len(ranks)
      result = int(
          self.MPI_LIB_CTYPES.horovod_add_process_set(
              (ctypes.c_int * nrank)(*ranks), ctypes.c_int(nrank)
          )
      )
      if result == self.HOROVOD_PROCESS_SET_ERROR_INIT:
          raise ValueError(
              "Horovod has not been initialized; use hvd.init()."
          )
      elif result == self.HOROVOD_PROCESS_SET_ERROR_SHUTDOWN:
          raise ValueError("Horovod is shutting down.")
      elif result == self.HOROVOD_PROCESS_SET_ERROR_DYNAMIC:
          raise ValueError(
              "Set HOROVOD_DYNAMIC_PROCESS_SETS=1 to allow adding process sets after Horovod initialization."
          )
      elif result == self.HOROVOD_PROCESS_SET_ERROR_EXISTING_SET:
          return None
      return result
  
imports: import atexit
  import ctypes
  import os
  from typing import *
  from horovod.common.process_sets import ProcessSet, global_process_set, _init_process_sets
  from horovod.common import util
label_desc: Use image node_id 24 for calling the HorovodBasics obj's underlying member method code with example usage: obj._add_process_set_impl(ranks) and returns: result, None