class_docstr: The `actor` (policy net) of DreamerV3.
  
  Consists of a simple MLP for Discrete actions and two MLPs for cont. actions (mean
  and stddev).
  Also contains two scalar variables to keep track of the percentile-5 and
  percentile-95 values of the computed value targets within a batch. This is used to
  compute the "scaled value targets" for actor learning. These two variables decay
  over time exponentially (see [1] for more details).
docstr: Initializes an ActorNetwork instance.
  
  Args:
       model_size: The "Model Size" used according to [1] Appendinx B.
          Use None for manually setting the different network sizes.
       action_space: The action space the our environment used.
code: def __init__(
      self,
      *,
      model_size: Optional[str] = "XS",
      action_space: gym.Space,
  ):
      """Initializes an ActorNetwork instance.
  
      Args:
           model_size: The "Model Size" used according to [1] Appendinx B.
              Use None for manually setting the different network sizes.
           action_space: The action space the our environment used.
      """
      super().__init__(name="actor")
  
      self.model_size = model_size
      self.action_space = action_space
  
      # The EMA decay variables used for the [Percentile(R, 95%) - Percentile(R, 5%)]
      # diff to scale value targets for the actor loss.
      self.ema_value_target_pct5 = tf.Variable(
          np.nan, trainable=False, name="value_target_pct5"
      )
      self.ema_value_target_pct95 = tf.Variable(
          np.nan, trainable=False, name="value_target_pct95"
      )
  
      # For discrete actions, use a single MLP that computes logits.
      if isinstance(self.action_space, Discrete):
          self.mlp = MLP(
              model_size=self.model_size,
              output_layer_size=self.action_space.n,
              name="actor_mlp",
          )
      # For cont. actions, use separate MLPs for Gaussian mean and stddev.
      # TODO (sven): In the author's original code repo, this is NOT the case,
      #  inputs are pushed through a shared MLP, then only the two output linear
      #  layers are separate for std- and mean logits.
      elif isinstance(action_space, Box):
          output_layer_size = np.prod(action_space.shape)
          self.mlp = MLP(
              model_size=self.model_size,
              output_layer_size=output_layer_size,
              name="actor_mlp_mean",
          )
          self.std_mlp = MLP(
              model_size=self.model_size,
              output_layer_size=output_layer_size,
              name="actor_mlp_std",
          )
      else:
          raise ValueError(f"Invalid action space: {action_space}")
  
      # Trace self.call.
      dl_type = (
          tf.keras.mixed_precision.global_policy().compute_dtype
          or tf.float32
      )
      self.call = tf.function(
          input_signature=[
              tf.TensorSpec(
                  shape=[None, get_gru_units(model_size)], dtype=dl_type
              ),
              tf.TensorSpec(
                  shape=[
                      None,
                      get_num_z_categoricals(model_size),
                      get_num_z_classes(model_size),
                  ],
                  dtype=dl_type,
              ),
          ]
      )(self.call)
  
file_path: ray/rllib/algorithms/dreamerv3/tf/models/actor_network.py
imports: from typing import Optional
  import gymnasium
  from gymnasium.spaces import Box, Discrete
  import numpy
  from ray.rllib.algorithms.dreamerv3.tf.models.components.mlp import MLP
  from ray.rllib.algorithms.dreamerv3.utils import get_gru_units, get_num_z_categoricals, get_num_z_classes
  from ray.rllib.utils.framework import try_import_tf, try_import_tfp
label_desc: Use image node_id 1 to create a new ActorNetwork object from inherited base classes: tf.keras with example: obj = ActorNetwork()