class_docstr: A class used to represent networks used by TF-Agents policies and agents.
  
  The main differences between a TF-Agents Network and a Keras Layer include:
  networks keep track of their underlying layers, explicitly represent RNN-like
  state in inputs and outputs, and simplify variable creation and clone
  operations.
  
  When calling a network `net`, typically one passes data through it via:
  
  ```python
  outputs, next_state = net(observation, network_state=...)
  outputs, next_state = net(observation, step_type=..., network_state=...)
  outputs, next_state = net(observation)  # net.call must fill an empty state
  outputs, next_state = net(observation, step_type=...)
  outputs, next_state = net(
      observation, step_type=..., network_state=..., learning=...)
  ```
  
  etc.
  
  To force construction of a network's variables:
  ```python
  net.create_variables()
  net.create_variables(input_tensor_spec=...)  # To provide an input spec
  net.create_variables(training=True)  # Provide extra kwargs
  net.create_variables(input_tensor_spec, training=True)
  ```
  
  To create a copy of the network:
  ```python
  cloned_net = net.copy()
  cloned_net.variables  # Raises ValueError: cloned net does not share weights.
  cloned_net.create_variables(...)
  cloned_net.variables  # Now new variables have been created.
  ```
class_docstr_tok: ["A","class","used","to","represent","networks","used","by","TF-Agents","policies","and","agents",".","The","main","differences","between","a","TF-Agents","Network","and","a","Keras","Layer","include",":","networks","keep","track","of","their","underlying","layers",",","explicitly","represent","RNN-like","state","in","inputs","and","outputs",",","and","simplify","variable","creation","and","clone","operations",".","When","calling","a","network","`","net","`",",","typically","one","passes","data","through","it","via",":","``","`","python","outputs",",","next_state","=","net","(","observation",",","network_state=","...",")","outputs",",","next_state","=","net","(","observation",",","step_type=","...",",","network_state=","...",")","outputs",",","next_state","=","net","(","observation",")","#","net.call","must","fill","an","empty","state","outputs",",","next_state","=","net","(","observation",",","step_type=","...",")","outputs",",","next_state","=","net","(","observation",",","step_type=","...",",","network_state=","...",",","learning=","...",")","``","`","etc",".","To","force","construction","of","a","network","'s","variables",":","``","`","python","net.create_variables","(",")","net.create_variables","(","input_tensor_spec=","...",")","#","To","provide","an","input","spec","net.create_variables","(","training=True",")","#","Provide","extra","kwargs","net.create_variables","(","input_tensor_spec",",","training=True",")","``","`","To","create","a","copy","of","the","network",":","``","`","python","cloned_net","=","net.copy","(",")","cloned_net.variables","#","Raises","ValueError",":","cloned","net","does","not","share","weights",".","cloned_net.create_variables","(","...",")","cloned_net.variables","#","Now","new","variables","have","been","created",".","``","`"]
docstr: A wrapper around `Network.call`.
  
  A typical `call` method in a class subclassing `Network` will have a
  signature that accepts `inputs`, as well as other `*args` and `**kwargs`.
  `call` can optionally also accept `step_type` and `network_state`
  (if `state_spec != ()` is not trivial).  e.g.:
  
  ```python
  def call(self,
           inputs,
           step_type=None,
           network_state=(),
           training=False):
      ...
      return outputs, new_network_state
  ```
  
  We will validate the first argument (`inputs`)
  against `self.input_tensor_spec` if one is available.
  
  If a `network_state` kwarg is given it is also validated against
  `self.state_spec`.  Similarly, the return value of the `call` method is
  expected to be a tuple/list with 2 values:  `(output, new_state)`.
  We validate `new_state` against `self.state_spec`.
  
  If no `network_state` kwarg is given (or if empty `network_state = ()` is
  given, it is up to `call` to assume a proper "empty" state, and to
  emit an appropriate `output_state`.
  
  Args:
    inputs: The input to `self.call`, matching `self.input_tensor_spec`.
    *args: Additional arguments to `self.call`.
    **kwargs: Additional keyword arguments to `self.call`. These can include
      `network_state` and `step_type`.  `step_type` is required if the
      network's `call` requires it. `network_state` is required if the
      underlying network's `call` requires it.
  
  Returns:
    A tuple `(outputs, new_network_state)`.
docstr_tok: ["A","wrapper","around","`","Network.call","`",".","A","typical","`","call","`","method","in","a","class","subclassing","`","Network","`","will","have","a","signature","that","accepts","`","inputs","`",",","as","well","as","other","`","*","args","`","and","`","*","*","kwargs","`",".","`","call","`","can","optionally","also","accept","`","step_type","`","and","`","network_state","`","(","if","`","state_spec","!","=","(",")","`","is","not","trivial",")",".","e.g",".",":","``","`","python","def","call","(","self",",","inputs",",","step_type=None",",","network_state=","(",")",",","training=False",")",":","...","return","outputs",",","new_network_state","``","`","We","will","validate","the","first","argument","(","`","inputs","`",")","against","`","self.input_tensor_spec","`","if","one","is","available",".","If","a","`","network_state","`","kwarg","is","given","it","is","also","validated","against","`","self.state_spec","`",".","Similarly",",","the","return","value","of","the","`","call","`","method","is","expected","to","be","a","tuple\/list","with","2","values",":","`","(","output",",","new_state",")","`",".","We","validate","`","new_state","`","against","`","self.state_spec","`",".","If","no","`","network_state","`","kwarg","is","given","(","or","if","empty","`","network_state","=","(",")","`","is","given",",","it","is","up","to","`","call","`","to","assume","a","proper","``","empty","''","state",",","and","to","emit","an","appropriate","`","output_state","`",".","Args",":","inputs",":","The","input","to","`","self.call","`",",","matching","`","self.input_tensor_spec","`",".","*","args",":","Additional","arguments","to","`","self.call","`",".","*","*","kwargs",":","Additional","keyword","arguments","to","`","self.call","`",".","These","can","include","`","network_state","`","and","`","step_type","`",".","`","step_type","`","is","required","if","the","network","'s","`","call","`","requires","it",".","`","network_state","`","is","required","if","the","underlying","network","'s","`","call","`","requires","it",".","Returns",":","A","tuple","`","(","outputs",",","new_network_state",")","`","."]
code: def __call__(self, inputs, *args, **kwargs):
      """A wrapper around `Network.call`.
  
      A typical `call` method in a class subclassing `Network` will have a
      signature that accepts `inputs`, as well as other `*args` and `**kwargs`.
      `call` can optionally also accept `step_type` and `network_state`
      (if `state_spec != ()` is not trivial).  e.g.:
  
      ```python
      def call(self,
               inputs,
               step_type=None,
               network_state=(),
               training=False):
          ...
          return outputs, new_network_state
      ```
  
      We will validate the first argument (`inputs`)
      against `self.input_tensor_spec` if one is available.
  
      If a `network_state` kwarg is given it is also validated against
      `self.state_spec`.  Similarly, the return value of the `call` method is
      expected to be a tuple/list with 2 values:  `(output, new_state)`.
      We validate `new_state` against `self.state_spec`.
  
      If no `network_state` kwarg is given (or if empty `network_state = ()` is
      given, it is up to `call` to assume a proper "empty" state, and to
      emit an appropriate `output_state`.
  
      Args:
        inputs: The input to `self.call`, matching `self.input_tensor_spec`.
        *args: Additional arguments to `self.call`.
        **kwargs: Additional keyword arguments to `self.call`. These can include
          `network_state` and `step_type`.  `step_type` is required if the
          network's `call` requires it. `network_state` is required if the
          underlying network's `call` requires it.
  
      Returns:
        A tuple `(outputs, new_network_state)`.
      """
      if self.input_tensor_spec is not None:
          nest_utils.assert_matching_dtypes_and_inner_shapes(
              inputs,
              self.input_tensor_spec,
              allow_extra_fields=True,
              caller=self,
              tensors_name="`inputs`",
              specs_name="`input_tensor_spec`",
          )
  
      call_argspec = tf_inspect.getargspec(self.call)
  
      # Convert *args, **kwargs to a canonical kwarg representation.
      normalized_kwargs = tf_inspect.getcallargs(
          self.call, inputs, *args, **kwargs
      )
      # TODO(b/156315434): Rename network_state to just state.
      network_state = normalized_kwargs.get("network_state", None)
      normalized_kwargs.pop("self", None)
  
      if common.safe_has_state(network_state):
          nest_utils.assert_matching_dtypes_and_inner_shapes(
              network_state,
              self.state_spec,
              allow_extra_fields=True,
              caller=self,
              tensors_name="`network_state`",
              specs_name="`state_spec`",
          )
  
      if (
          "step_type" not in call_argspec.args
          and not call_argspec.keywords
      ):
          normalized_kwargs.pop("step_type", None)
  
      # network_state can be a (), None, Tensor or NestedTensors.
      if (
          not tf.is_tensor(network_state)
          and network_state in (None, ())
          and "network_state" not in call_argspec.args
          and not call_argspec.keywords
      ):
          normalized_kwargs.pop("network_state", None)
  
      outputs, new_state = super(Network, self).__call__(
          **normalized_kwargs
      )  # pytype: disable=attribute-error  # typed-keras
  
      nest_utils.assert_matching_dtypes_and_inner_shapes(
          new_state,
          self.state_spec,
          allow_extra_fields=True,
          caller=self,
          tensors_name="`new_state`",
          specs_name="`state_spec`",
      )
  
      return outputs, new_state
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import typing
  import six
  import tensorflow
  import tensorflow_probability
  from tf_agents.distributions import utils
  from tf_agents.networks import layer_utils
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
  from tf_agents.utils import object_identity
  from tensorflow.python.trackable import base
  from tensorflow.python.util import tf_decorator
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 11 for calling the Network obj's underlying member method code with example usage: obj.__call__(inputs) and returns: outputs,  new_state