class_docstr: Tests various connectors.
      
docstr: Tests the logic of
  :class:`~texar.tf.modules.StochasticConnector`.
docstr_tok: ["Tests","the","logic","of",":","class",":","`","~texar.tf.modules.StochasticConnector","`","."]
code: def test_stochastic_connector(self):
      """Tests the logic of
      :class:`~texar.tf.modules.StochasticConnector`.
      """
      state_size = (10, 10)
      variable_size = 100
      state_size_ts = tf.TensorShape([self._batch_size, variable_size])
      gauss_connector = StochasticConnector(state_size)
      mu = tf.zeros([self._batch_size, variable_size])
      var = tf.ones([self._batch_size, variable_size])
      gauss_ds = tfpd.MultivariateNormalDiag(loc=mu, scale_diag=var)
      output_1, _ = gauss_connector(gauss_ds)
  
      gauss_connector_2 = StochasticConnector(state_size_ts)
      output_2, sample2 = gauss_connector_2(
          distribution="MultivariateNormalDiag",
          distribution_kwargs={"loc": mu, "scale_diag": var},
          transform=False,
      )
      test_list = [output_1, output_2, sample2]
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          out_list = sess.run(test_list)
          out1 = out_list[0]
          out2 = out_list[1]
          sample2 = out_list[2]
          self.assertEqual(
              out1[0].shape,
              tf.TensorShape([self._batch_size, state_size[0]]),
          )
          self.assertEqual(out2.shape, state_size_ts)
          self.assertEqual(out2.shape, sample2.shape)
  
file_path: texar/tests/modules/connectors/connectors_test.py
imports: import tensorflow
  from tensorflow_probability import distributions
  from tensorflow.python.util import nest
  from texar.tf.core import layers
  from texar.tf.modules import ConstantConnector
  from texar.tf.modules import MLPTransformConnector
  from texar.tf.modules import ReparameterizedStochasticConnector, StochasticConnector
  from texar.tf.modules.connectors.connectors import _assert_same_size
label_desc: Use image node_id 6 for calling the TestConnectors obj's underlying member method code with example usage: obj.test_stochastic_connector() without return types