class_docstr: Samples from a distribution with reparameterization trick, and
  transforms samples into specified size.
  
  Reparameterization allows gradients to be back-propagated through the
  stochastic samples. Used in, e.g., Variational Autoencoders (VAEs).
  
  Args:
      output_size: Size of output **excluding** the batch dimension. For
          example, set `output_size` to `dim` to generate output of
          shape `[batch_size, dim]`.
          Can be an `int`, a tuple of `int`, a Tensorshape, or a tuple of
          TensorShapes.
          For example, to transform inputs to have decoder state size, set
          `output_size=decoder.state_size`.
      hparams (dict, optional): Hyperparameters. Missing
          hyperparamerter will be set to default values. See
          :meth:`default_hparams` for the hyperparameter sturcture and
          default values.
  
  Example:
  
      .. code-block:: python
  
          cell = LSTMCell(num_units=256)
          # cell.state_size == LSTMStateTuple(c=256, h=256)
  
          connector = ReparameterizedStochasticConnector(cell.state_size)
  
          kwargs = {
              'loc': tf.zeros([batch_size, 10]),
              'scale_diag': tf.ones([batch_size, 10])
          }
          output, sample = connector(distribution_kwargs=kwargs)
          # output == LSTMStateTuple(c=tensor_of_shape_(batch_size, 256),
          #                          h=tensor_of_shape_(batch_size, 256))
          # sample == Tensor([batch_size, 10])
  
  
          kwargs = {
              'loc': tf.zeros([10]),
              'scale_diag': tf.ones([10])
          }
          output_, sample_ = connector(distribution_kwargs=kwargs,
                                       num_samples=batch_size_)
          # output_ == LSTMStateTuple(c=tensor_of_shape_(batch_size_, 256),
          #                           h=tensor_of_shape_(batch_size_, 256))
          # sample == Tensor([batch_size_, 10])
  
  .. document private functions
  .. automethod:: _build
class_docstr_tok: ["Samples","from","a","distribution","with","reparameterization","trick",",","and","transforms","samples","into","specified","size",".","Reparameterization","allows","gradients","to","be","back-propagated","through","the","stochastic","samples",".","Used","in",",","e.g.",",","Variational","Autoencoders","(","VAEs",")",".","Args",":","output_size",":","Size","of","output","*","*","excluding","*","*","the","batch","dimension",".","For","example",",","set","`","output_size","`","to","`","dim","`","to","generate","output","of","shape","`","[","batch_size",",","dim","]","`",".","Can","be","an","`","int","`",",","a","tuple","of","`","int","`",",","a","Tensorshape",",","or","a","tuple","of","TensorShapes",".","For","example",",","to","transform","inputs","to","have","decoder","state","size",",","set","`","output_size=decoder.state_size","`",".","hparams","(","dict",",","optional",")",":","Hyperparameters",".","Missing","hyperparamerter","will","be","set","to","default","values",".","See",":","meth",":","`","default_hparams","`","for","the","hyperparameter","sturcture","and","default","values",".","Example",":","..","code-block",":",":","python","cell","=","LSTMCell","(","num_units=256",")","#","cell.state_size","==","LSTMStateTuple","(","c=256",",","h=256",")","connector","=","ReparameterizedStochasticConnector","(","cell.state_size",")","kwargs","=","{","'loc","'",":","tf.zeros","(","[","batch_size",",","10","]",")",",","'scale_diag","'",":","tf.ones","(","[","batch_size",",","10","]",")","}","output",",","sample","=","connector","(","distribution_kwargs=kwargs",")","#","output","==","LSTMStateTuple","(","c=tensor_of_shape_","(","batch_size",",","256",")",",","#","h=tensor_of_shape_","(","batch_size",",","256",")",")","#","sample","==","Tensor","(","[","batch_size",",","10","]",")","kwargs","=","{","'loc","'",":","tf.zeros","(","[","10","]",")",",","'scale_diag","'",":","tf.ones","(","[","10","]",")","}","output_",",","sample_","=","connector","(","distribution_kwargs=kwargs",",","num_samples=batch_size_",")","#","output_","==","LSTMStateTuple","(","c=tensor_of_shape_","(","batch_size_",",","256",")",",","#","h=tensor_of_shape_","(","batch_size_",",","256",")",")","#","sample","==","Tensor","(","[","batch_size_",",","10","]",")","..","document","private","functions","..","automethod",":",":","_build"]
docstr: Returns a dictionary of hyperparameters with default values.
  
  .. code-block:: python
  
      {
          "activation_fn": "identity",
          "name": "reparameterized_stochastic_connector"
      }
  
  Here:
  
  "activation_fn": str
      The activation function applied to the outputs of the MLP
      transformation layer. Can
      be a function, or its name or module path.
  
  "name": str
      Name of the connector.
docstr_tok: ["Returns","a","dictionary","of","hyperparameters","with","default","values",".","..","code-block",":",":","python","{","``","activation_fn","''",":","``","identity","''",",","``","name","''",":","``","reparameterized_stochastic_connector","''","}","Here",":","''","activation_fn","''",":","str","The","activation","function","applied","to","the","outputs","of","the","MLP","transformation","layer",".","Can","be","a","function",",","or","its","name","or","module","path",".","``","name","''",":","str","Name","of","the","connector","."]
code: def default_hparams():
      """Returns a dictionary of hyperparameters with default values.
  
      .. code-block:: python
  
          {
              "activation_fn": "identity",
              "name": "reparameterized_stochastic_connector"
          }
  
      Here:
  
      "activation_fn": str
          The activation function applied to the outputs of the MLP
          transformation layer. Can
          be a function, or its name or module path.
  
      "name": str
          Name of the connector.
      """
      return {
          "activation_fn": "tensorflow.identity",
          "name": "reparameterized_stochastic_connector",
      }
  
imports: import numpy
  import tensorflow
  from tensorflow import distributions
  from tensorflow.python.util import nest
  from texar.tf.modules.connectors.connector_base import ConnectorBase
  from texar.tf.core import layers
  from texar.tf.utils.utils import get_function, check_or_get_instance
label_desc: Use image node_id 2 for calling the ReparameterizedStochasticConnector obj's underlying member method code with example usage: obj.default_hparams() and returns: dict