docstr: Test correct handling of `TensorShape(None)`.
docstr_tok: ["Test","correct","handling","of","`","TensorShape","(","None",")","`","."]
code: def test_dynamic_batch_shape(self):
      """Test correct handling of `TensorShape(None)`."""
      if JAX_MODE:
          self.skipTest("b/203858802")
      if tf.executing_eagerly():
          self.skipTest("Eager does not support dynamic batch shapes.")
  
      n_features = 5
      n_timepoints = 100
      features = normal.Normal(0.0, 1.0).sample(
          [100, n_features], test_util.test_seed()
      )
      ar_sigma = 1.0
      rho = 0.25
  
      @jdc.JointDistributionCoroutine
      def jd_model():
          beta = yield Root(
              sample.Sample(normal.Normal(0.0, 1.0), n_features)
          )
          yhat = tf.einsum("ij,...j->...i", features, beta)
  
          def ar_fun(y):
              loc = tf.concat(
                  [tf.zeros_like(y[..., :1]), y[..., :-1]], axis=-1
              )
              return independent.Independent(
                  normal.Normal(loc=loc * rho, scale=ar_sigma),
                  reinterpreted_batch_ndims=1,
              )
  
          # Autoregressive distribution defined as below introduce a batch shape:
          # TensorShape(None)
          yield autoregressive.Autoregressive(
              distribution_fn=ar_fun,
              sample0=tf.zeros_like(yhat),
              num_steps=yhat.shape[-1],
              name="y",
          )
  
      states, _ = self.evaluate(
          windowed_sampling.windowed_adaptive_nuts(
              2,
              jd_model,
              num_adaptation_steps=25,
              n_chains=3,
              seed=test_util.test_seed(),
          )
      )
      self.assertEqual((2, 3, n_timepoints), states.y.shape)
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import identity
  from tensorflow_probability.python.bijectors import pad
  from tensorflow_probability.python.distributions import autoregressive
  from tensorflow_probability.python.distributions import beta_binomial
  from tensorflow_probability.python.distributions import dirichlet
  from tensorflow_probability.python.distributions import half_normal
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import joint_distribution_auto_batched
  from tensorflow_probability.python.distributions import joint_distribution_coroutine
  from tensorflow_probability.python.distributions import joint_distribution_named
  from tensorflow_probability.python.distributions import joint_distribution_sequential
  from tensorflow_probability.python.distributions import multinomial
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import poisson
  from tensorflow_probability.python.distributions import sample
  from tensorflow_probability.python.distributions import uniform
  from tensorflow_probability.python.experimental import distribute
  from tensorflow_probability.python.experimental.mcmc import windowed_sampling
  from tensorflow_probability.python.internal import callable_util
  from tensorflow_probability.python.internal import distribute_test_lib
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.internal import unnest
  from tensorflow_probability.python.mcmc import diagnostic
label_desc: Use image node_id 17 for calling the WindowedSamplingTest obj's underlying member method code with example usage: obj.test_dynamic_batch_shape() and returns: independent