class_docstr: Describes the sub-module-architectures to be used in RLModules.
  
  RLlib's native RLModules get their Models from a Catalog object.
  By default, that Catalog builds the configs it has as attributes.
  This component was build to be hackable and extensible. You can inject custom
  components into RL Modules by overriding the `build_xxx` methods of this class.
  Note that it is recommended to write a custom RL Module for a single use-case.
  Modifications to Catalogs mostly make sense if you want to reuse the same
  Catalog for different RL Modules. For example if you have written a custom
  encoder and want to inject it into different RL Modules (e.g. for PPO, DQN, etc.).
  You can influence the decision tree that determines the sub-components by modifying
  `Catalog._determine_components_hook`.
  
  Usage example:
  
  # Define a custom catalog
  
  .. testcode::
  
      import torch
      import gymnasium as gym
      from ray.rllib.core.models.configs import MLPHeadConfig
      from ray.rllib.core.models.catalog import Catalog
  
      class MyCatalog(Catalog):
          def __init__(
              self,
              observation_space: gym.Space,
              action_space: gym.Space,
              model_config_dict: dict,
          ):
              super().__init__(observation_space, action_space, model_config_dict)
              self.my_model_config = MLPHeadConfig(
                  hidden_layer_dims=[64, 32],
                  input_dims=[self.observation_space.shape[0]],
              )
  
          def build_my_head(self, framework: str):
              return self.my_model_config.build(framework=framework)
  
      # With that, RLlib can build and use models from this catalog like this:
      catalog = MyCatalog(gym.spaces.Box(0, 1), gym.spaces.Box(0, 1), {})
      my_head = catalog.build_my_head(framework="torch")
  
      # Make a call to the built model.
      out = my_head(torch.Tensor([[1]]))
class_docstr_tok: ["Describes","the","sub-module-architectures","to","be","used","in","RLModules",".","RLlib","'s","native","RLModules","get","their","Models","from","a","Catalog","object",".","By","default",",","that","Catalog","builds","the","configs","it","has","as","attributes",".","This","component","was","build","to","be","hackable","and","extensible",".","You","can","inject","custom","components","into","RL","Modules","by","overriding","the","`","build_xxx","`","methods","of","this","class",".","Note","that","it","is","recommended","to","write","a","custom","RL","Module","for","a","single","use-case",".","Modifications","to","Catalogs","mostly","make","sense","if","you","want","to","reuse","the","same","Catalog","for","different","RL","Modules",".","For","example","if","you","have","written","a","custom","encoder","and","want","to","inject","it","into","different","RL","Modules","(","e.g",".","for","PPO",",","DQN",",","etc.",")",".","You","can","influence","the","decision","tree","that","determines","the","sub-components","by","modifying","`","Catalog._determine_components_hook","`",".","Usage","example",":","#","Define","a","custom","catalog","..","testcode",":",":","import","torch","import","gymnasium","as","gym","from","ray.rllib.core.models.configs","import","MLPHeadConfig","from","ray.rllib.core.models.catalog","import","Catalog","class","MyCatalog","(","Catalog",")",":","def","__init__","(","self",",","observation_space",":","gym.Space",",","action_space",":","gym.Space",",","model_config_dict",":","dict",",",")",":","super","(",")",".__init__","(","observation_space",",","action_space",",","model_config_dict",")","self.my_model_config","=","MLPHeadConfig","(","hidden_layer_dims=","[","64",",","32","]",",","input_dims=","[","self.observation_space.shape","[","0","]","]",",",")","def","build_my_head","(","self",",","framework",":","str",")",":","return","self.my_model_config.build","(","framework=framework",")","#","With","that",",","RLlib","can","build","and","use","models","from","this","catalog","like","this",":","catalog","=","MyCatalog","(","gym.spaces.Box","(","0",",","1",")",",","gym.spaces.Box","(","0",",","1",")",",","{","}",")","my_head","=","catalog.build_my_head","(","framework=","''","torch","''",")","#","Make","a","call","to","the","built","model",".","out","=","my_head","(","torch.Tensor","(","[","[","1","]","]",")",")"]
docstr: Decision tree hook for subclasses to override.
  
  By default, this method executes the decision tree that determines the
  components that a Catalog builds. You can extend the components by overriding
  this or by adding to the constructor of your subclass.
  
  Override this method if you don't want to use the default components
  determined here. If you want to use them but add additional components, you
  should call `super()._determine_components()` at the beginning of your
  implementation.
  
  This makes it so that subclasses are not forced to create an encoder config
  if the rest of their catalog is not dependent on it or if it breaks.
  At the end of this method, an attribute `Catalog.latent_dims`
  should be set so that heads can be built using that information.
docstr_tok: ["Decision","tree","hook","for","subclasses","to","override",".","By","default",",","this","method","executes","the","decision","tree","that","determines","the","components","that","a","Catalog","builds",".","You","can","extend","the","components","by","overriding","this","or","by","adding","to","the","constructor","of","your","subclass",".","Override","this","method","if","you","do","n't","want","to","use","the","default","components","determined","here",".","If","you","want","to","use","them","but","add","additional","components",",","you","should","call","`","super","(",")","._determine_components","(",")","`","at","the","beginning","of","your","implementation",".","This","makes","it","so","that","subclasses","are","not","forced","to","create","an","encoder","config","if","the","rest","of","their","catalog","is","not","dependent","on","it","or","if","it","breaks",".","At","the","end","of","this","method",",","an","attribute","`","Catalog.latent_dims","`","should","be","set","so","that","heads","can","be","built","using","that","information","."]
code: def _determine_components_hook(self):
      """Decision tree hook for subclasses to override.
  
      By default, this method executes the decision tree that determines the
      components that a Catalog builds. You can extend the components by overriding
      this or by adding to the constructor of your subclass.
  
      Override this method if you don't want to use the default components
      determined here. If you want to use them but add additional components, you
      should call `super()._determine_components()` at the beginning of your
      implementation.
  
      This makes it so that subclasses are not forced to create an encoder config
      if the rest of their catalog is not dependent on it or if it breaks.
      At the end of this method, an attribute `Catalog.latent_dims`
      should be set so that heads can be built using that information.
      """
      self._encoder_config = self._get_encoder_config(
          observation_space=self.observation_space,
          action_space=self.action_space,
          model_config_dict=self._model_config_dict,
          view_requirements=self._view_requirements,
      )
  
      # Create a function that can be called when framework is known to retrieve the
      # class type for action distributions
      self._action_dist_class_fn = functools.partial(
          self._get_dist_cls_from_action_space,
          action_space=self.action_space,
      )
  
      # The dimensions of the latent vector that is output by the encoder and fed
      # to the heads.
      self.latent_dims = self._encoder_config.output_dims
  
imports: import enum
  import functools
  from typing import Optional
  import gymnasium
  import numpy
  import tree
  from gymnasium.spaces import Box, Dict, Discrete, MultiDiscrete, Tuple
  from ray.rllib.core.models.base import Encoder
  from ray.rllib.core.models.configs import CNNEncoderConfig, MLPEncoderConfig, RecurrentEncoderConfig
  from ray.rllib.core.models.configs import ModelConfig
  from ray.rllib.models import MODEL_DEFAULTS
  from ray.rllib.models.distributions import Distribution
  from ray.rllib.models.preprocessors import get_preprocessor, Preprocessor
  from ray.rllib.models.utils import get_filter_config
  from ray.rllib.utils.deprecation import deprecation_warning
  from ray.rllib.utils.error import UnsupportedSpaceException
  from ray.rllib.utils.spaces.simplex import Simplex
  from ray.rllib.utils.spaces.space_utils import flatten_space
  from ray.rllib.utils.spaces.space_utils import get_base_struct_from_space
  from ray.rllib.utils.typing import ViewRequirementsDict
  from ray.rllib.utils.annotations import OverrideToImplementCustomLogic, OverrideToImplementCustomLogic_CallToSuperRecommended
label_desc: Use image node_id 2 for calling the Catalog obj's underlying member method code with example usage: obj._determine_components_hook() without return types