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: Force creation of the network's variables.
  
  Return output specs.
  
  Args:
    input_tensor_spec: (Optional).  Override or provide an input tensor spec
      when creating variables.
    **kwargs: Other arguments to `network.call()`, e.g. `training=True`.
  
  Returns:
    Output specs - a nested spec calculated from the outputs (excluding any
    batch dimensions).  If any of the output elements is a tfp `Distribution`,
    the associated spec entry returned is a `DistributionSpec`.
  
  Raises:
    ValueError: If no `input_tensor_spec` is provided, and the network did
      not provide one during construction.
docstr_tok: ["Force","creation","of","the","network","'s","variables",".","Return","output","specs",".","Args",":","input_tensor_spec",":","(","Optional",")",".","Override","or","provide","an","input","tensor","spec","when","creating","variables",".","*","*","kwargs",":","Other","arguments","to","`","network.call","(",")","`",",","e.g",".","`","training=True","`",".","Returns",":","Output","specs","-","a","nested","spec","calculated","from","the","outputs","(","excluding","any","batch","dimensions",")",".","If","any","of","the","output","elements","is","a","tfp","`","Distribution","`",",","the","associated","spec","entry","returned","is","a","`","DistributionSpec","`",".","Raises",":","ValueError",":","If","no","`","input_tensor_spec","`","is","provided",",","and","the","network","did","not","provide","one","during","construction","."]
code: def create_variables(self, input_tensor_spec=None, **kwargs):
      """Force creation of the network's variables.
  
      Return output specs.
  
      Args:
        input_tensor_spec: (Optional).  Override or provide an input tensor spec
          when creating variables.
        **kwargs: Other arguments to `network.call()`, e.g. `training=True`.
  
      Returns:
        Output specs - a nested spec calculated from the outputs (excluding any
        batch dimensions).  If any of the output elements is a tfp `Distribution`,
        the associated spec entry returned is a `DistributionSpec`.
  
      Raises:
        ValueError: If no `input_tensor_spec` is provided, and the network did
          not provide one during construction.
      """
      if self._network_output_spec is not None:
          return self._network_output_spec
      if self._input_tensor_spec is None:
          self._input_tensor_spec = input_tensor_spec
      input_tensor_spec = self._input_tensor_spec
      if input_tensor_spec is None:
          raise ValueError(
              "Unable to create_variables: no input_tensor_spec provided, and "
              "Network did not define one."
          )
  
      random_input = tensor_spec.sample_spec_nest(
          input_tensor_spec, outer_dims=(1,)
      )
      initial_state = self.get_initial_state(batch_size=1)
      step_type = tf.fill((1,), time_step.StepType.FIRST)
      outputs = self.__call__(
          random_input,
          step_type=step_type,
          network_state=initial_state,
          **kwargs,
      )
  
      def _calc_unbatched_spec(x):
          """Build Network output spec by removing previously added batch dimension.
  
          Args:
            x: tfp.distributions.Distribution or Tensor.
  
          Returns:
            Specs without batch dimension representing x.
          """
          if isinstance(x, tfp.distributions.Distribution):
              parameters = distribution_utils.get_parameters(x)
              parameter_specs = (
                  _convert_to_spec_and_remove_singleton_batch_dim(
                      parameters, outer_ndim=1
                  )
              )
              return distribution_utils.DistributionSpecV2(
                  event_shape=x.event_shape,
                  dtype=x.dtype,
                  parameters=parameter_specs,
              )
          else:
              return tensor_spec.remove_outer_dims_nest(
                  tf.type_spec_from_value(x), num_outer_dims=1
              )
  
      self._network_output_spec = tf.nest.map_structure(
          _calc_unbatched_spec, outputs[0]
      )
      return self._network_output_spec
  
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 4 for calling the Network obj's underlying member method code with example usage: obj.create_variables(input_tensor_spec) and returns: self, self, distribution_utils, tensor_spec