class_docstr: Composes template models from configs.
  
  :param action_spaces_dict: Dict of sub-step id to action space.
  :param observation_spaces_dict: Dict of sub-step id to observation space.
  :param distribution_mapper_config: Distribution mapper configuration.
  :param model_builder: The model builder (template) to create the model from.
  :param policy: Specifies the policy type as a configType.
      E.g. {'type': maze.perception.models.policies.ProbabilisticPolicyComposer} specifies a probabilistic policy.
  :param critic: Specifies the critic type as a configType.
      E.g. {'type': maze.perception.models.critics.StateCriticComposer} specifies the single step state critic.
class_docstr_tok: ["Composes","template","models","from","configs",".",":","param","action_spaces_dict",":","Dict","of","sub-step","id","to","action","space",".",":","param","observation_spaces_dict",":","Dict","of","sub-step","id","to","observation","space",".",":","param","distribution_mapper_config",":","Distribution","mapper","configuration",".",":","param","model_builder",":","The","model","builder","(","template",")","to","create","the","model","from",".",":","param","policy",":","Specifies","the","policy","type","as","a","configType",".","E.g",".","{","'type","'",":","maze.perception.models.policies.ProbabilisticPolicyComposer","}","specifies","a","probabilistic","policy",".",":","param","critic",":","Specifies","the","critic","type","as","a","configType",".","E.g",".","{","'type","'",":","maze.perception.models.critics.StateCriticComposer","}","specifies","the","single","step","state","critic","."]
code: def __init__(
      self,
      action_spaces_dict: Dict[StepKeyType, spaces.Dict],
      observation_spaces_dict: Dict[StepKeyType, spaces.Dict],
      agent_counts_dict: Dict[StepKeyType, int],
      distribution_mapper_config: ConfigType,
      model_builder: Union[ConfigType, Type[BaseModelBuilder]],
      policy: ConfigType,
      critic: ConfigType,
  ):
      super().__init__(
          action_spaces_dict,
          observation_spaces_dict,
          agent_counts_dict,
          distribution_mapper_config,
      )
  
      self._policy_type = (
          Factory(BasePolicyComposer).type_from_name(policy["_target_"])
          if policy is not None
          else None
      )
      self._critic_type = (
          Factory(CriticComposerInterface).type_from_name(
              critic["_target_"]
          )
          if critic is not None
          else None
      )
      self.model_builder = Factory(BaseModelBuilder).instantiate(
          model_builder
      )
  
      self.model_builder.init_shared_embedding_keys(
          self.action_spaces_dict.keys()
      )
      assert (
          self.model_builder.shared_embedding_keys.keys()
          == self.observation_spaces_dict.keys()
      )
      self._shared_embedding_nets: Dict[
          StepKeyType, InferenceBlock
      ] = dict()
  
      self.save_models()
  
imports: import functools
  from typing import Optional, Dict, Union, Type, Tuple, List
  from gym import spaces
  from maze.core.agent.torch_policy import TorchPolicy
  from maze.core.agent.torch_state_action_critic import TorchSharedStateActionCritic, TorchStateActionCritic, TorchStepStateActionCritic
  from maze.core.agent.torch_state_critic import TorchStateCritic, TorchSharedStateCritic, TorchStepStateCritic, TorchDeltaStateCritic
  from maze.core.annotations import override
  from maze.core.env.structured_env import StepKeyType
  from maze.core.utils.factory import ConfigType, Factory
  from maze.core.utils.structured_env_utils import flat_structured_space
  from maze.core.wrappers.observation_preprocessing.preprocessors.one_hot import OneHotPreProcessor
  from maze.perception.blocks.inference import InferenceBlock
  from maze.perception.blocks.output.linear import LinearOutputBlock
  from maze.perception.builders.base import BaseModelBuilder
  from maze.perception.models.critics import SharedStateCriticComposer, DeltaStateCriticComposer, StepStateCriticComposer
  from maze.perception.models.critics.critic_composer_interface import CriticComposerInterface
  from maze.perception.models.critics.shared_state_action_critics_composer import SharedStateActionCriticComposer
  from maze.perception.models.critics.step_state_action_critic_composer import StepStateActionCriticComposer
  from maze.perception.models.model_composer import BaseModelComposer
  from maze.perception.models.policies.base_policy_composer import BasePolicyComposer
  from maze.perception.models.policies.probabilistic_policy_composer import ProbabilisticPolicyComposer
  from maze.perception.weight_init import make_module_init_normc
  from maze.utils.bcolors import BColors
label_desc: Use image node_id 2 to create a new TemplateModelComposer object from inherited base classes: BaseModelComposer with example: obj = TemplateModelComposer(action_spaces_dict, observation_spaces_dict, agent_counts_dict, distribution_mapper_config, model_builder, policy, critic)