class_docstr: Tests various connectors.
      
docstr: Tests the logic of
  :class:`~texar.tf.modules.ReparameterizedStochasticConnector`.
docstr_tok: ["Tests","the","logic","of",":","class",":","`","~texar.tf.modules.ReparameterizedStochasticConnector","`","."]
code: def test_reparameterized_stochastic_connector(self):
      """Tests the logic of
      :class:`~texar.tf.modules.ReparameterizedStochasticConnector`.
      """
      state_size = (10, 10)
      variable_size = 100
      state_size_ts = (
          tf.TensorShape([10, 10]),
          tf.TensorShape([2, 3, 4]),
      )
      sample_num = 10
  
      mu = tf.zeros([self._batch_size, variable_size])
      var = tf.ones([self._batch_size, variable_size])
      mu_vec = tf.zeros([variable_size])
      var_vec = tf.ones([variable_size])
      gauss_ds = tfpd.MultivariateNormalDiag(loc=mu, scale_diag=var)
      gauss_ds_vec = tfpd.MultivariateNormalDiag(
          loc=mu_vec, scale_diag=var_vec
      )
      gauss_connector = ReparameterizedStochasticConnector(state_size)
      gauss_connector_ts = ReparameterizedStochasticConnector(
          state_size_ts
      )
  
      output_1, _ = gauss_connector(gauss_ds)
      output_2, _ = gauss_connector(
          distribution="MultivariateNormalDiag",
          distribution_kwargs={"loc": mu, "scale_diag": var},
      )
      sample_ts, _ = gauss_connector_ts(gauss_ds)
  
      # specify sample num
      sample_test_num, _ = gauss_connector(
          gauss_ds_vec, num_samples=sample_num
      )
  
      # test when :attr:`transform` is False
      # sample_test_no_transform = gauss_connector(gauss_ds, transform=False)
  
      test_list = [output_1, output_2, sample_ts, sample_test_num]
  
      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]
          out_ts = out_list[2]
          out_test_num = out_list[3]
  
          # check the same size
          self.assertEqual(
              out_test_num[0].shape,
              tf.TensorShape([sample_num, state_size[0]]),
          )
          self.assertEqual(
              out1[0].shape,
              tf.TensorShape([self._batch_size, state_size[0]]),
          )
          self.assertEqual(
              out2[0].shape,
              tf.TensorShape([self._batch_size, state_size[0]]),
          )
          _assert_same_size(out_ts, state_size_ts)
  
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 5 for calling the TestConnectors obj's underlying member method code with example usage: obj.test_reparameterized_stochastic_connector() without return types