class_docstr: Policy which parametrizes independent action-/advantage-/state-value functions per action and
  optionally a state-value function, conditioned on the output of a central neural network
  processing the input state (specification key: `parametrized_value_policy`).
  
  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/state
          value functions, via registered tensors with name "[ACTION]-embedding" or
          "state-embedding"/"[ACTION]-state-embedding" depending on the state_value_mode argument
          (<span style="color:#00C000"><b>default</b></span>: single output).
      state_value_mode ('implicit' | 'separate' | 'separate-per-action'): Whether to compute the
          state value implicitly as maximum action value (like DQN), or as either a single
          separate state-value function or a function per action (like DuelingDQN)
          (<span style="color:#00C000"><b>default</b></span>: single separate state-value
          function).
      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","action-\/advantage-\/state-value","functions","per","action","and","optionally","a","state-value","function",",","conditioned","on","the","output","of","a","central","neural","network","processing","the","input","state","(","specification","key",":","`","parametrized_value_policy","`",")",".","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\/state","value","functions",",","via","registered","tensors","with","name","``","[","ACTION","]","-embedding","''","or","``","state-embedding","''","\/","''","[","ACTION","]","-state-embedding","''","depending","on","the","state_value_mode","argument","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","single","output",")",".","state_value_mode","(","'implicit","'","|","'separate","'","|","'separate-per-action","'",")",":","Whether","to","compute","the","state","value","implicitly","as","maximum","action","value","(","like","DQN",")",",","or","as","either","a","single","separate","state-value","function","or","a","function","per","action","(","like","DuelingDQN",")","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","single","separate","state-value","function",")",".","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,
      state_value_mode="separate",
      device=None,
      l2_regularization=None,
      name=None,
      states_spec=None,
      auxiliaries_spec=None,
      internals_spec=None,
      actions_spec=None,
  ):
      super().__init__(
          device=device,
          l2_regularization=l2_regularization,
          name=name,
          states_spec=states_spec,
          auxiliaries_spec=auxiliaries_spec,
          actions_spec=actions_spec,
      )
  
      if not all(
          spec.type in ("bool", "int")
          for spec in self.actions_spec.values()
      ):
          raise TensorforceError.value(
              name="ParametrizedValuePolicy",
              argument="actions_spec",
              value=actions_spec,
              hint="types not bool/int",
          )
  
      # State value mode
      if state_value_mode not in (
          "implicit",
          "separate",
          "separate-per-action",
      ):
          raise TensorforceError.value(
              name="ParametrizedValuePolicy",
              argument="state_value_mode",
              value=state_value_mode,
              hint="not from {implicit,separate,separate-per-action}",
          )
      self.state_value_mode = state_value_mode
  
      if single_output:
          outputs = None
      elif self.actions_spec.is_singleton():
          if self.state_value_mode == "implicit":
              outputs = ("action-embedding",)
          else:
              outputs = ("action-embedding", "state-embedding")
      else:
          outputs = tuple(
              name + "-embedding" for name in self.actions_spec
          )
          if self.state_value_mode == "separate":
              outputs += ("state-embedding",)
          elif self.state_value_mode == "separate-per-action":
              outputs += tuple(
                  name + "-state-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)
  
      # Action values
      def function(name, spec):
          if name is None:
              input_name = "action-embedding"
              name = "action_value"
          else:
              input_name = name + "-embedding"
              name = name + "_action_value"
          if spec.type == "bool":
              return self.submodule(
                  name=name,
                  module="linear",
                  modules=layer_modules,
                  size=(spec.size * 2),
                  input_spec=output_spec.get(
                      input_name, output_spec["embedding"]
                  ),
              )
          elif spec.type == "int":
              return self.submodule(
                  name=name,
                  module="linear",
                  modules=layer_modules,
                  size=(spec.size * spec.num_values),
                  input_spec=output_spec.get(
                      input_name, output_spec["embedding"]
                  ),
              )
  
      self.a_values = self.actions_spec.fmap(
          function=function, cls=ModuleDict, with_names=True
      )
  
      if self.state_value_mode == "separate":
          # State value
          self.s_value = self.submodule(
              name="value",
              module="linear",
              modules=layer_modules,
              size=0,
              input_spec=output_spec.get(
                  "state-embedding", output_spec["embedding"]
              ),
          )
  
      elif self.state_value_mode == "separate-per-action":
          # State values per action
  
          def function(name, spec):
              if name is None:
                  input_name = "state-embedding"
                  name = "state_value"
              else:
                  input_name = name + "-state-embedding"
                  name = name + "_state_value"
              return self.submodule(
                  name=name,
                  module="linear",
                  modules=layer_modules,
                  size=spec.size,
                  input_spec=output_spec.get(
                      input_name, output_spec["embedding"]
                  ),
              )
  
          self.s_values = self.states_spec.fmap(
              function=function, cls=ModuleDict, with_names=True
          )
  
file_path: tensorforce/tensorforce/core/policies/parametrized_value_policy.py
imports: import tensorflow
  from tensorforce import TensorforceError
  from tensorforce.core import layer_modules, ModuleDict, TensorDict, TensorSpec, TensorsSpec, tf_function, tf_util
  from tensorforce.core.policies import ParametrizedPolicy, ValuePolicy
label_desc: Use image node_id 1 to create a new ParametrizedValuePolicy object from inherited base classes: ValuePolicy, ParametrizedPolicy with example: obj = ParametrizedValuePolicy(network)