code: def add_policy(self, policy_id: PolicyID, policy_spec: PolicySpec):
      # Merge the policies config overrides with the main config.
      # Also, adjust `num_gpus` (to indicate an individual policy's
      # num_gpus, not the total number of GPUs).
      cfg = Algorithm.merge_trainer_configs(
          self.config,
          dict(
              policy_spec.config,
              **{"num_gpus": self.num_gpus_per_policy},
          ),
      )
  
      # Need to create the replay actor first. Then add the first policy.
      if self.replay_actor is None:
          return self._add_replay_buffer_and_policy(
              policy_id, policy_spec, cfg
          )
  
      # Replay actor already exists -> Just add a new policy here.
  
      assert len(self.policy_actors) < self.max_num_policies
  
      actual_policy_class = get_tf_eager_cls_if_necessary(
          policy_spec.policy_class, cfg
      )
  
      colocated = create_colocated_actors(
          actor_specs=[
              (
                  ray.remote(
                      num_cpus=1,
                      num_gpus=self.num_gpus_per_policy
                      if not cfg["_fake_gpus"]
                      else 0,
                  )(actual_policy_class),
                  # Policy c'tor args.
                  (
                      policy_spec.observation_space,
                      policy_spec.action_space,
                      cfg,
                  ),
                  # Policy c'tor kwargs={}.
                  {},
                  # Count=1,
                  1,
              )
          ],
          # Force co-locate on the already existing replay actor's node.
          node=ray.get(self.replay_actor.get_host.remote()),
      )
  
      self.policy_actors[policy_id] = colocated[0][0]
  
      return self.policy_actors[policy_id]
  
imports: import math
  from typing import Any, Dict, List, Optional, Type
  import ray
  from ray.actor import ActorHandle
  from ray.rllib.algorithms.algorithm import Algorithm
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
  from ray.rllib.policy.policy import PolicySpec
  from ray.rllib.utils.actors import create_colocated_actors
  from ray.rllib.utils.tf_utils import get_tf_eager_cls_if_necessary
  from ray.rllib.utils.typing import AlgorithmConfigDict, PolicyID
label_desc: Use image node_id 2 for calling the _Shard obj's underlying member method code with example usage: obj.add_policy(policy_id, policy_spec) and returns: self, self