class_docstr: Policy which parametrizes independent distributions per action, conditioned on the output of a
  central neural network processing the input state, supporting both a stochastic and value-based
  policy interface (specification key: `parametrized_distributions`).
  
  Args:
      network ('auto' | specification): Policy network configuration, see
          [networks](../modules/networks.html)
          (<span style="color:#00C000"><b>default</b></span>: 'auto', automatically configured
          network).
      single_output (bool): Whether the network returns a single embedding tensor or, in the case
          of multiple action components, specifies additional outputs for some/all action
          distributions, via registered tensors with name "[ACTION]-embedding"
          (<span style="color:#00C000"><b>default</b></span>: single output).
      distributions (dict[specification]): Distributions configuration, see
          [distributions](../modules/distributions.html), specified per
          action-type or -name
          (<span style="color:#00C000"><b>default</b></span>: per action-type, Bernoulli
          distribution for binary boolean actions, categorical distribution for discrete integer
          actions, Gaussian distribution for unbounded continuous actions, Beta distribution for
          bounded continuous actions).
      temperature (parameter | dict[parameter], float >= 0.0): Sampling temperature, global or
          per action (<span style="color:#00C000"><b>default</b></span>: 1.0).
      use_beta_distribution (bool): Whether to use the Beta distribution for bounded continuous
          actions by default.
          (<span style="color:#00C000"><b>default</b></span>: false).
      device (string): Device name
          (<span style="color:#00C000"><b>default</b></span>: inherit value of parent module).
      l2_regularization (float >= 0.0): Scalar controlling L2 regularization
          (<span style="color:#00C000"><b>default</b></span>: inherit value of parent module).
      name (string): <span style="color:#0000C0"><b>internal use</b></span>.
      states_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
      auxiliaries_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
      internals_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
      actions_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
class_docstr_tok: ["Policy","which","parametrizes","independent","distributions","per","action",",","conditioned","on","the","output","of","a","central","neural","network","processing","the","input","state",",","supporting","both","a","stochastic","and","value-based","policy","interface","(","specification","key",":","`","parametrized_distributions","`",")",".","Args",":","network","(","'auto","'","|","specification",")",":","Policy","network","configuration",",","see","[","networks","]","(","..","\/modules\/networks.html",")","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","'auto","'",",","automatically","configured","network",")",".","single_output","(","bool",")",":","Whether","the","network","returns","a","single","embedding","tensor","or",",","in","the","case","of","multiple","action","components",",","specifies","additional","outputs","for","some\/all","action","distributions",",","via","registered","tensors","with","name","``","[","ACTION","]","-embedding","''","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","single","output",")",".","distributions","(","dict","[","specification","]",")",":","Distributions","configuration",",","see","[","distributions","]","(","..","\/modules\/distributions.html",")",",","specified","per","action-type","or","-name","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","per","action-type",",","Bernoulli","distribution","for","binary","boolean","actions",",","categorical","distribution","for","discrete","integer","actions",",","Gaussian","distribution","for","unbounded","continuous","actions",",","Beta","distribution","for","bounded","continuous","actions",")",".","temperature","(","parameter","|","dict","[","parameter","]",",","float",">","=","0.0",")",":","Sampling","temperature",",","global","or","per","action","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","1.0",")",".","use_beta_distribution","(","bool",")",":","Whether","to","use","the","Beta","distribution","for","bounded","continuous","actions","by","default",".","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","false",")",".","device","(","string",")",":","Device","name","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","inherit","value","of","parent","module",")",".","l2_regularization","(","float",">","=","0.0",")",":","Scalar","controlling","L2","regularization","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","inherit","value","of","parent","module",")",".","name","(","string",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","states_spec","(","specification",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","auxiliaries_spec","(","specification",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","internals_spec","(","specification",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","actions_spec","(","specification",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">","."]
code: def __init__(
      self,
      network="auto",
      *,
      single_output=True,
      distributions=None,
      temperature=1.0,
      use_beta_distribution=False,
      device=None,
      l2_regularization=None,
      name=None,
      states_spec=None,
      auxiliaries_spec=None,
      internals_spec=None,
      actions_spec=None,
  ):
      super().__init__(
          temperature=temperature,
          device=device,
          l2_regularization=l2_regularization,
          name=name,
          states_spec=states_spec,
          auxiliaries_spec=auxiliaries_spec,
          actions_spec=actions_spec,
      )
  
      if single_output:
          outputs = None
      elif self.actions_spec.is_singleton():
          outputs = ("action-embedding",)
      else:
          outputs = tuple(
              name + "-embedding" for name in self.actions_spec
          )
      ParametrizedPolicy.__init__(
          self=self,
          network=network,
          inputs_spec=self.states_spec,
          outputs=outputs,
      )
      output_spec = self.network.output_spec()
      if not isinstance(output_spec, TensorsSpec):
          output_spec = TensorsSpec(embedding=output_spec)
  
      # Distributions
      self.distributions = ModuleDict()
      for name, spec in self.actions_spec.items():
          if spec.type == "bool":
              default_module = "bernoulli"
          elif spec.type == "int":
              assert spec.num_values is not None
              default_module = "categorical"
          elif spec.type == "float":
              if use_beta_distribution and spec.min_value is not None:
                  default_module = "beta"
              else:
                  default_module = "gaussian"
  
          if distributions is None:
              module = None
          else:
              module = dict()
              if name is None and isinstance(distributions, str):
                  module = distributions
              elif name in distributions:
                  if isinstance(distributions[name], str):
                      module = distributions[name]
                  else:
                      module.update(distributions[name])
              elif spec.type in distributions:
                  if isinstance(distributions[spec.type], str):
                      module = distributions[spec.type]
                  else:
                      module.update(distributions[spec.type])
              elif name is None and "type" in distributions:
                  module.update(distributions)
  
          if name is None:
              self.distributions[name] = self.submodule(
                  name="action_distribution",
                  module=module,
                  modules=distribution_modules,
                  default_module=default_module,
                  action_spec=spec,
                  input_spec=output_spec.get(
                      "action-embedding", output_spec["embedding"]
                  ),
              )
          else:
              self.distributions[name] = self.submodule(
                  name=(name + "_distribution"),
                  module=module,
                  modules=distribution_modules,
                  default_module=default_module,
                  action_spec=spec,
                  input_spec=output_spec.get(
                      name + "-embedding", output_spec["embedding"]
                  ),
              )
  
      self.kldiv_reference_spec = self.distributions.fmap(
          function=(lambda x: x.parameters_spec), cls=TensorsSpec
      )
  
file_path: tensorforce/tensorforce/core/policies/parametrized_distributions.py
imports: import tensorflow
  from tensorforce.core import distribution_modules, ModuleDict, TensorDict, TensorsSpec, tf_function, tf_util
  from tensorforce.core.policies import ParametrizedPolicy, StochasticPolicy, ValuePolicy
label_desc: Use image node_id 1 to create a new ParametrizedDistributions object from inherited base classes: StochasticPolicy, ValuePolicy, ParametrizedPolicy with example: obj = ParametrizedDistributions(network)