class_docstr: Job class for Horovod + Ray integration.
  
  Args:
      settings (horovod.Settings): Configuration for job setup. You can
          use a standard Horovod Settings object or create one directly
          from RayExecutor.create_settings.
      num_workers (int): Number of workers to use for training.
      cpus_per_worker (int): Number of CPU resources to allocate to
          each worker.
      use_gpu (bool): Whether to use GPU for allocation. TODO: this
          can be removed.
      gpus_per_worker (int): Number of GPU resources to allocate to
          each worker.
      num_hosts (int): Alternative API to ``num_workers``. Number of
          machines to execute the job on. Used to enforce equal number of
          workers on each machine.
      num_workers_per_host (int): Alternative API to
          ``num_workers``. Number of workers to be placed on each machine.
          Used to enforce equal number of workers on each machine. Only
          used in conjunction with `num_hosts`.
      use_current_placement_group (bool): Whether to use the current
          placement group instead of creating a new one. Defaults to True.
      min_workers (int): Minimum number of processes running for
          training to continue. If number of available processes dips
          below this threshold, then training will wait for
          more instances to become available.
      max_workers (int): Maximum number of training processes,
          beyond which no additional processes will be created.
          If not specified, then will be unbounded.
      reset_limit (int): Maximum number of times that the training
          job can scale up or down the number of workers after
          which the job is terminated.
      elastic_timeout (int): Timeout for elastic initialisation after
          re-scaling the cluster. The default value is 600 seconds.
          Alternatively, the environment variable
          HOROVOD_ELASTIC_TIMEOUT can also be used.
      override_discovery (bool): Whether for the ElasticRayExecutor to
          automatically provide a discovery mechanism for ElasticSettings.
class_docstr_tok: ["Job","class","for","Horovod","+","Ray","integration",".","Args",":","settings","(","horovod.Settings",")",":","Configuration","for","job","setup",".","You","can","use","a","standard","Horovod","Settings","object","or","create","one","directly","from","RayExecutor.create_settings",".","num_workers","(","int",")",":","Number","of","workers","to","use","for","training",".","cpus_per_worker","(","int",")",":","Number","of","CPU","resources","to","allocate","to","each","worker",".","use_gpu","(","bool",")",":","Whether","to","use","GPU","for","allocation",".","TODO",":","this","can","be","removed",".","gpus_per_worker","(","int",")",":","Number","of","GPU","resources","to","allocate","to","each","worker",".","num_hosts","(","int",")",":","Alternative","API","to","``","num_workers","``",".","Number","of","machines","to","execute","the","job","on",".","Used","to","enforce","equal","number","of","workers","on","each","machine",".","num_workers_per_host","(","int",")",":","Alternative","API","to","``","num_workers","``",".","Number","of","workers","to","be","placed","on","each","machine",".","Used","to","enforce","equal","number","of","workers","on","each","machine",".","Only","used","in","conjunction","with","`","num_hosts","`",".","use_current_placement_group","(","bool",")",":","Whether","to","use","the","current","placement","group","instead","of","creating","a","new","one",".","Defaults","to","True",".","min_workers","(","int",")",":","Minimum","number","of","processes","running","for","training","to","continue",".","If","number","of","available","processes","dips","below","this","threshold",",","then","training","will","wait","for","more","instances","to","become","available",".","max_workers","(","int",")",":","Maximum","number","of","training","processes",",","beyond","which","no","additional","processes","will","be","created",".","If","not","specified",",","then","will","be","unbounded",".","reset_limit","(","int",")",":","Maximum","number","of","times","that","the","training","job","can","scale","up","or","down","the","number","of","workers","after","which","the","job","is","terminated",".","elastic_timeout","(","int",")",":","Timeout","for","elastic","initialisation","after","re-scaling","the","cluster",".","The","default","value","is","600","seconds",".","Alternatively",",","the","environment","variable","HOROVOD_ELASTIC_TIMEOUT","can","also","be","used",".","override_discovery","(","bool",")",":","Whether","for","the","ElasticRayExecutor","to","automatically","provide","a","discovery","mechanism","for","ElasticSettings","."]
code: def _initialize_adapter(self):
      kwargs = asdict(self.params)
      logger.debug(f"Kwargs: {kwargs}")
      Adapter = self.params.adapter
      self._is_remote = False
      if ray.util.client.ray.is_connected():
          RemoteAdapter = ray.remote(Adapter)
          self.adapter = RemoteAdapter.remote(self.settings, **kwargs)
          self._is_remote = True
      else:
          self.adapter = Adapter(self.settings, **kwargs)
  
imports: import ray
  from ray.util.placement_group import get_current_placement_group
  from collections import defaultdict
  from dataclasses import dataclass, asdict
  import os
  from typing import Dict, Callable, Any, Optional, List
  import logging
  import ray.exceptions
  from horovod.ray.adapter import Adapter, BaseParams
  from horovod.runner.common.util import secret, timeout, hosts
  from horovod.runner.http.http_server import RendezvousServer
  from horovod.ray.utils import detect_nics, nics_to_env_var, map_blocking
  from horovod.ray.strategy import ColocatedStrategy, PGStrategy
  from horovod.ray.elastic_v2 import ElasticParams
label_desc: Use image node_id 4 for calling the RayExecutor obj's underlying member method code with example usage: obj._initialize_adapter() without return types