class_docstr: Registry of models, preprocessors, and action distributions for envs.
  
  .. testcode::
      :skipif: True
  
      prep = ModelCatalog.get_preprocessor(env)
      observation = prep.transform(raw_observation)
  
      dist_class, dist_dim = ModelCatalog.get_action_dist(
          env.action_space, {})
      model = ModelCatalog.get_model_v2(
          obs_space, action_space, num_outputs, options)
      dist = dist_class(model.outputs, model)
      action = dist.sample()
class_docstr_tok: ["Registry","of","models",",","preprocessors",",","and","action","distributions","for","envs",".","..","testcode",":",":",":","skipif",":","True","prep","=","ModelCatalog.get_preprocessor","(","env",")","observation","=","prep.transform","(","raw_observation",")","dist_class",",","dist_dim","=","ModelCatalog.get_action_dist","(","env.action_space",",","{","}",")","model","=","ModelCatalog.get_model_v2","(","obs_space",",","action_space",",","num_outputs",",","options",")","dist","=","dist_class","(","model.outputs",",","model",")","action","=","dist.sample","(",")"]
docstr: Validates a given model config dict.
  
  Args:
      config: The "model" sub-config dict
          within the Algorithm's config dict.
      action_space: The action space of the model, whose config are
              validated.
      framework: One of "jax", "tf2", "tf", or "torch".
  
  Raises:
      ValueError: If something is wrong with the given config.
docstr_tok: ["Validates","a","given","model","config","dict",".","Args",":","config",":","The","``","model","''","sub-config","dict","within","the","Algorithm","'s","config","dict",".","action_space",":","The","action","space","of","the","model",",","whose","config","are","validated",".","framework",":","One","of","``","jax","''",",","``","tf2","''",",","``","tf","''",",","or","``","torch","''",".","Raises",":","ValueError",":","If","something","is","wrong","with","the","given","config","."]
code: def _validate_config(
      config: ModelConfigDict,
      action_space: gym.spaces.Space,
      framework: str,
  ) -> None:
      """Validates a given model config dict.
  
      Args:
          config: The "model" sub-config dict
              within the Algorithm's config dict.
          action_space: The action space of the model, whose config are
                  validated.
          framework: One of "jax", "tf2", "tf", or "torch".
  
      Raises:
          ValueError: If something is wrong with the given config.
      """
      # Soft-deprecate custom preprocessors.
      if config.get("custom_preprocessor") is not None:
          deprecation_warning(
              old="model.custom_preprocessor",
              new="gym.ObservationWrapper around your env or handle complex "
              "inputs inside your Model",
              error=True,
          )
  
      if config.get("use_attention") and config.get("use_lstm"):
          raise ValueError(
              "Only one of `use_lstm` or `use_attention` may be set to True!"
          )
  
      # For complex action spaces, only allow prev action inputs to
      # LSTMs and attention nets iff `_disable_action_flattening=True`.
      # TODO: `_disable_action_flattening=True` will be the default in
      #  the future.
      if (
          (
              config.get("lstm_use_prev_action")
              or config.get("attention_use_n_prev_actions", 0) > 0
          )
          and not config.get("_disable_action_flattening")
          and isinstance(action_space, (Tuple, Dict))
      ):
          raise ValueError(
              "For your complex action space (Tuple|Dict) and your model's "
              "`prev-actions` setup of your model, you must set "
              "`_disable_action_flattening=True` in your main config dict!"
          )
  
      if framework == "jax":
          if config.get("use_attention"):
              raise ValueError(
                  "`use_attention` not available for framework=jax so far!"
              )
          elif config.get("use_lstm"):
              raise ValueError(
                  "`use_lstm` not available for framework=jax so far!"
              )
  
imports: from functools import partial
  import gymnasium
  from gymnasium.spaces import Box, Dict, Discrete, MultiDiscrete, Tuple
  import logging
  import numpy
  import tree
  from typing import List, Optional, Type, Union
  from ray.tune.registry import RLLIB_MODEL, RLLIB_ACTION_DIST, _global_registry
  from ray.rllib.models.action_dist import ActionDistribution
  from ray.rllib.models.modelv2 import ModelV2
  from ray.rllib.models.preprocessors import get_preprocessor, Preprocessor
  from ray.rllib.models.tf.tf_action_dist import Categorical, Deterministic, DiagGaussian, Dirichlet, MultiActionDistribution, MultiCategorical
  from ray.rllib.models.torch.torch_action_dist import TorchCategorical, TorchDeterministic, TorchDirichlet, TorchDiagGaussian, TorchMultiActionDistribution, TorchMultiCategorical
  from ray.rllib.utils.annotations import DeveloperAPI, PublicAPI
  from ray.rllib.utils.deprecation import DEPRECATED_VALUE, deprecation_warning
  from ray.rllib.utils.error import UnsupportedSpaceException
  from ray.rllib.utils.framework import try_import_tf, try_import_torch
  from ray.rllib.utils.from_config import from_config
  from ray.rllib.utils.spaces.simplex import Simplex
  from ray.rllib.utils.spaces.space_utils import flatten_space
  from ray.rllib.utils.typing import ModelConfigDict, TensorType
label_desc: Use image node_id 12 for calling the ModelCatalog obj's underlying member method code with example usage: obj._validate_config(config, action_space, framework) without return types