class_docstr: Optimizer function for VTrace torch policies.
code: def optimizer(
      self,
  ) -> Union[List["torch.optim.Optimizer"], "torch.optim.Optimizer"]:
      if self.config["_separate_vf_optimizer"]:
          # Figure out, which parameters of the model belong to the value
          # function (and which to the policy net).
          dummy_batch = self._lazy_tensor_dict(
              self._get_dummy_batch_from_view_requirements()
          )
          # Zero out all gradients (set to None)
          for param in self.model.parameters():
              param.grad = None
          # Perform a dummy forward pass (through the policy net, which should be
          # separated from the value function in this particular user setup).
          out = self.model(dummy_batch)
          # Perform a (dummy) backward pass to be able to see, which params have
          # gradients and are therefore used for the policy computations (vs vf
          # computations).
          torch.sum(
              out[0]
          ).backward()  # [0] -> Model returns out and state-outs.
          # Collect policy vs value function params separately.
          policy_params = []
          value_params = []
          for param in self.model.parameters():
              if param.grad is None:
                  value_params.append(param)
              else:
                  policy_params.append(param)
          if self.config["opt_type"] == "adam":
              return (
                  torch.optim.Adam(
                      params=policy_params, lr=self.cur_lr
                  ),
                  torch.optim.Adam(
                      params=value_params, lr=self.config["_lr_vf"]
                  ),
              )
          else:
              raise NotImplementedError
  
      if self.config["opt_type"] == "adam":
          return torch.optim.Adam(
              params=self.model.parameters(), lr=self.cur_lr
          )
      else:
          return torch.optim.RMSprop(
              params=self.model.parameters(),
              lr=self.cur_lr,
              weight_decay=self.config["decay"],
              momentum=self.config["momentum"],
              eps=self.config["epsilon"],
          )
  
imports: import gymnasium
  import logging
  import numpy
  from typing import Dict, List, Optional, Type, Union
  import ray
  from ray.rllib.evaluation.episode import Episode
  from ray.rllib.evaluation.postprocessing import compute_bootstrap_value
  from ray.rllib.models.modelv2 import ModelV2
  from ray.rllib.models.action_dist import ActionDistribution
  from ray.rllib.models.torch.torch_action_dist import TorchCategorical
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.policy.torch_mixins import EntropyCoeffSchedule, LearningRateSchedule, ValueNetworkMixin
  from ray.rllib.policy.torch_policy_v2 import TorchPolicyV2
  from ray.rllib.utils.annotations import override
  from ray.rllib.utils.framework import try_import_torch
  from ray.rllib.utils.numpy import convert_to_numpy
  from ray.rllib.utils.torch_utils import apply_grad_clipping, explained_variance, global_norm, sequence_mask
  from ray.rllib.utils.typing import TensorType
label_desc: Use image node_id 2 for calling the VTraceOptimizer obj's underlying member method code with example usage: obj.optimizer() and returns: torch, torch, torch,  torch