class_docstr: A policy that chooses from a set of policies to decide the action.
class_docstr_tok: ["A","policy","that","chooses","from","a","set","of","policies","to","decide","the","action","."]
docstr: Initializes an instance of `MixturePolicy`.
  
  Args:
    mixture_distribution: A `tfd.Categorical` distribution on the domain `[0,
      len(policies) -1]`. This distribution is used by the mixture policy to
      choose which policy to listen to.
    policies: List of TF Policies. These are the policies that the mixture
      policy chooses from in every time step.
    name: The name of this instance of `MixturePolicy`.
docstr_tok: ["Initializes","an","instance","of","`","MixturePolicy","`",".","Args",":","mixture_distribution",":","A","`","tfd.Categorical","`","distribution","on","the","domain","`","[","0",",","len","(","policies",")","-1","]","`",".","This","distribution","is","used","by","the","mixture","policy","to","choose","which","policy","to","listen","to",".","policies",":","List","of","TF","Policies",".","These","are","the","policies","that","the","mixture","policy","chooses","from","in","every","time","step",".","name",":","The","name","of","this","instance","of","`","MixturePolicy","`","."]
code: def __init__(
      self,
      mixture_distribution: types.Distribution,
      policies: Sequence[tf_policy.TFPolicy],
      name: Optional[Text] = None,
  ):
      """Initializes an instance of `MixturePolicy`.
  
      Args:
        mixture_distribution: A `tfd.Categorical` distribution on the domain `[0,
          len(policies) -1]`. This distribution is used by the mixture policy to
          choose which policy to listen to.
        policies: List of TF Policies. These are the policies that the mixture
          policy chooses from in every time step.
        name: The name of this instance of `MixturePolicy`.
      """
      self._policies = policies
      if not isinstance(mixture_distribution, tfd.Categorical):
          raise TypeError(
              "mixture distribution must be an instance of `tfd.Categorical`."
          )
      self._mixture_distribution = mixture_distribution
      action_spec = policies[0].action_spec
      time_step_spec = policies[0].time_step_spec
      for policy in policies[1:]:
          assert (
              action_spec == policy.action_spec
          ), "Inconsistent action specs."
          assert (
              time_step_spec == policy.time_step_spec
          ), "Inconsistent time step specs."
          assert (
              policies[0].info_spec == policy.info_spec
          ), "Inconsistent info specs."
  
      info_spec = {
          MIXTURE_AGENT_ID: tensor_spec.BoundedTensorSpec(
              shape=(),
              dtype=tf.int32,
              minimum=0,
              maximum=len(policies) - 1,
          ),
          SUBPOLICY_INFO: policies[0].info_spec,
      }
  
      super(MixturePolicy, self).__init__(
          time_step_spec=time_step_spec,
          action_spec=action_spec,
          info_spec=info_spec,
          name=name,
      )
  
file_path: agents/tf_agents/bandits/policies/mixture_policy.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Optional, Sequence, Text
  import gin
  import tensorflow
  import tensorflow_probability
  from tf_agents.policies import tf_policy
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.typing import types
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 1 to create a new MixturePolicy object from inherited base classes: tf_policy with example: obj = MixturePolicy(mixture_distribution, policies, name)