class_docstr: Model class for TensorFlow.
  
  A TfModel only contains the structure/configuration of the underlying
  computation graphs. Connectivity information are all in Network class.
  A TfModel contains zero or more Network.
  
  When a Network is created, it reuses the parameter from the
  model. If a Network is built without given a name, the name "default" will
  be used.
  
  ***
  Do not call tf.global_variable_initializers() after building a model as it
  will reassign random weights to the model.
  The parameters inside a model will be initialized when calling build().
  ***
  
  Pickling is handled automatcailly. The target weights should be assigned to
  self._default_parameters before pickling, so that the newly created model
  can check if target weights exist or not. When unpickled, the unserialized
  model will load the weights from self._default_parameters.
  
  The design is illustrated as the following:
  
       input_1                      input_2
          |                            |
  ============== Model (TfModel)===================
  |       |                            |          |
  |       |            Parameters      |          |
  |    =============  /           \  ============ |
  |    |  default  | /             \ | Network2 | |
  |    | (Network) |/               \|(Network) | |
  |    =============                 ============ |
  |       |                            |          |
  =================================================
          |                            |
          |                            |
  (outputs from 'default' networks)    |
                      outputs from ['Network2'] network
  
  
  Examples are also available in tests/garage/tf/models/test_model.
  
  Args:
    name (str): Name of the model. It will also become the variable scope
        of the model. Every model should have a unique name.
class_docstr_tok: ["Model","class","for","TensorFlow",".","A","TfModel","only","contains","the","structure\/configuration","of","the","underlying","computation","graphs",".","Connectivity","information","are","all","in","Network","class",".","A","TfModel","contains","zero","or","more","Network",".","When","a","Network","is","created",",","it","reuses","the","parameter","from","the","model",".","If","a","Network","is","built","without","given","a","name",",","the","name","``","default","''","will","be","used",".","*","*","*","Do","not","call","tf.global_variable_initializers","(",")","after","building","a","model","as","it","will","reassign","random","weights","to","the","model",".","The","parameters","inside","a","model","will","be","initialized","when","calling","build","(",")",".","*","*","*","Pickling","is","handled","automatcailly",".","The","target","weights","should","be","assigned","to","self._default_parameters","before","pickling",",","so","that","the","newly","created","model","can","check","if","target","weights","exist","or","not",".","When","unpickled",",","the","unserialized","model","will","load","the","weights","from","self._default_parameters",".","The","design","is","illustrated","as","the","following",":","input_1","input_2","|","|","==============","Model","(","TfModel",")","===================","|","|","|","|","|","|","Parameters","|","|","|","=============","\/","\\","============","|","|","|","default","|","\/","\\","|","Network2","|","|","|","|","(","Network",")","|\/","\\|","(","Network",")","|","|","|","=============","============","|","|","|","|","|","=================================================","|","|","|","|","(","outputs","from","'default","'","networks",")","|","outputs","from","[","'Network2","'","]","network","Examples","are","also","available","in","tests\/garage\/tf\/models\/test_model",".","Args",":","name","(","str",")",":","Name","of","the","model",".","It","will","also","become","the","variable","scope","of","the","model",".","Every","model","should","have","a","unique","name","."]
docstr: Build a Network with the given input(s).
  
  ***
  Do not call tf.global_variable_initializers() after building a model
  as it will reassign random weights to the model.
  The parameters inside a model will be initialized when calling build().
  ***
  
  It uses the same, fixed variable scope for all Networks, to ensure
  parameter sharing. Different Networks must have an unique name.
  
  Args:
      inputs (list[tf.Tensor]) : Tensor input(s), recommended to be
          positional arguments, for example,
          def build(self, state_input, action_input, name=None).
      name (str): Name of the model, which is also the name scope of the
          model.
  
  Raises:
      ValueError: When a Network with the same name is already built.
  
  Returns:
      list[tf.Tensor]: Output tensors of the model with the given
          inputs.
docstr_tok: ["Build","a","Network","with","the","given","input","(","s",")",".","*","*","*","Do","not","call","tf.global_variable_initializers","(",")","after","building","a","model","as","it","will","reassign","random","weights","to","the","model",".","The","parameters","inside","a","model","will","be","initialized","when","calling","build","(",")",".","*","*","*","It","uses","the","same",",","fixed","variable","scope","for","all","Networks",",","to","ensure","parameter","sharing",".","Different","Networks","must","have","an","unique","name",".","Args",":","inputs","(","list","[","tf.Tensor","]",")",":","Tensor","input","(","s",")",",","recommended","to","be","positional","arguments",",","for","example",",","def","build","(","self",",","state_input",",","action_input",",","name=None",")",".","name","(","str",")",":","Name","of","the","model",",","which","is","also","the","name","scope","of","the","model",".","Raises",":","ValueError",":","When","a","Network","with","the","same","name","is","already","built",".","Returns",":","list","[","tf.Tensor","]",":","Output","tensors","of","the","model","with","the","given","inputs","."]
code: def build(self, *inputs, name=None):
      """Build a Network with the given input(s).
  
      ***
      Do not call tf.global_variable_initializers() after building a model
      as it will reassign random weights to the model.
      The parameters inside a model will be initialized when calling build().
      ***
  
      It uses the same, fixed variable scope for all Networks, to ensure
      parameter sharing. Different Networks must have an unique name.
  
      Args:
          inputs (list[tf.Tensor]) : Tensor input(s), recommended to be
              positional arguments, for example,
              def build(self, state_input, action_input, name=None).
          name (str): Name of the model, which is also the name scope of the
              model.
  
      Raises:
          ValueError: When a Network with the same name is already built.
  
      Returns:
          list[tf.Tensor]: Output tensors of the model with the given
              inputs.
  
      """
      network_name = name or "default"
      if not self._networks:
          # First time building the model, so self._networks are empty
          # We store the variable_scope to reenter later when we reuse it
          with tf.compat.v1.variable_scope(self._name) as vs:
              self._variable_scope = vs
              with tf.name_scope(name=network_name):
                  network = Network()
                  network._inputs = inputs
                  network._outputs = self._build(*inputs, name)
              variables = self._get_variables().values()
              tf.compat.v1.get_default_session().run(
                  tf.compat.v1.variables_initializer(variables)
              )
              if self._default_parameters:
                  self.parameters = self._default_parameters
      else:
          if network_name in self._networks:
              raise ValueError(
                  "Network {} already exists!".format(network_name)
              )
          with tf.compat.v1.variable_scope(
              self._variable_scope,
              reuse=True,
              auxiliary_name_scope=False,
          ):
              with tf.name_scope(name=network_name):
                  network = Network()
                  network._inputs = inputs
                  network._outputs = self._build(*inputs, name)
      custom_in_spec = self.network_input_spec()
      custom_out_spec = self.network_output_spec()
      in_spec = ["input", "inputs"]
      out_spec = ["output", "outputs"]
      in_args = [network.input, network.inputs]
      out_args = [network.output, network.outputs]
      if isinstance(network.inputs, tuple) and len(network.inputs) > 1:
          assert len(custom_in_spec) == len(
              network.inputs
          ), "network_input_spec must have same length as inputs!"
          in_spec.extend(custom_in_spec)
          in_args.extend(network.inputs)
      if (
          isinstance(network.outputs, tuple)
          and len(network.outputs) > 1
      ):
          assert len(custom_out_spec) == len(
              network.outputs
          ), "network_output_spec must have same length as outputs!"
          out_spec.extend(custom_out_spec)
          out_args.extend(network.outputs)
      elif len(custom_out_spec) > 0:
          if not isinstance(network.outputs, tuple):
              assert (
                  len(custom_out_spec) == 1
              ), "network_input_spec must have same length as outputs!"
              out_spec.extend(custom_out_spec)
              out_args.extend([network.outputs])
          else:
              assert len(custom_out_spec) == len(
                  network.outputs
              ), "network_input_spec must have same length as outputs!"
              out_spec.extend(custom_out_spec)
              out_args.extend(network.outputs)
  
      c = namedtuple(network_name, [*in_spec, *out_spec])
      all_args = in_args + out_args
      out_network = c(*all_args)
      self._networks[network_name] = out_network
  
      return out_network
  
imports: import abc
  from collections import namedtuple
  import warnings
  import tensorflow
  from garage.tf.models.module import Module
label_desc: Use image node_id 2 for calling the Model obj's underlying member method code with example usage: obj.build() and returns: out_network