code: def test_variable_shape_change(self):
      loc = tf.Variable(tf.zeros([4, 5, 3]), shape=tf.TensorShape(None))
      scale = tf.Variable(tf.ones([]), shape=tf.TensorShape(None))
      # In real life, you'd really always want `sample_shape` to be
      # `trainable=False`.
      sample_shape = tf.Variable([1, 2], shape=tf.TensorShape(None))
      dist = sample.Sample(
          independent.Independent(
              logistic.Logistic(loc=loc, scale=scale),
              reinterpreted_batch_ndims=1,
          ),
          sample_shape=sample_shape,
          validate_args=True,
      )
      self.evaluate([v.initializer for v in dist.trainable_variables])
  
      x = dist.mean()
      y = dist.sample([7, 2], seed=test_util.test_seed())
      loss_x = -dist.log_prob(x)
      loss_0 = -dist.log_prob(0.0)
      batch_shape = dist.batch_shape_tensor()
      event_shape = dist.event_shape_tensor()
      [
          x_,
          y_,
          loss_x_,
          loss_0_,
          batch_shape_,
          event_shape_,
      ] = self.evaluate(
          [x, y, loss_x, loss_0, batch_shape, event_shape]
      )
      self.assertAllEqual([4, 5, 1, 2, 3], x_.shape)
      self.assertAllEqual([7, 2, 4, 5, 1, 2, 3], y_.shape)
      self.assertAllEqual([4, 5], loss_x_.shape)
      self.assertAllEqual([4, 5], loss_0_.shape)
      self.assertAllEqual([4, 5], batch_shape_)
      self.assertAllEqual([1, 2, 3], event_shape_)
      self.assertLen(dist.trainable_variables, 3)
  
      with tf.control_dependencies(
          [
              loc.assign(tf.zeros([])),
              scale.assign(tf.ones([3, 1, 2])),
              sample_shape.assign(6),
          ]
      ):
          x = dist.mean()
          y = dist.sample([7, 2], seed=test_util.test_seed())
          loss_x = -dist.log_prob(x)
          loss_0 = -dist.log_prob(0.0)
          batch_shape = dist.batch_shape_tensor()
          event_shape = dist.event_shape_tensor()
      [
          x_,
          y_,
          loss_x_,
          loss_0_,
          batch_shape_,
          event_shape_,
      ] = self.evaluate(
          [x, y, loss_x, loss_0, batch_shape, event_shape]
      )
      self.assertAllEqual([3, 1, 6, 2], x_.shape)
      self.assertAllEqual([7, 2, 3, 1, 6, 2], y_.shape)
      self.assertAllEqual([3, 1], loss_x_.shape)
      self.assertAllEqual([3, 1], loss_0_.shape)
      self.assertAllEqual([3, 1], batch_shape_)
      self.assertAllEqual([6, 2], event_shape_)
      self.assertLen(dist.trainable_variables, 3)
  
imports: import functools
  import os
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import exp
  from tensorflow_probability.python.bijectors import scale
  from tensorflow_probability.python.bijectors import scale_matvec_tril
  from tensorflow_probability.python.distributions import cholesky_lkj
  from tensorflow_probability.python.distributions import exponential
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.distributions import log_prob_ratio
  from tensorflow_probability.python.distributions import logistic
  from tensorflow_probability.python.distributions import lognormal
  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 transformed_distribution
  from tensorflow_probability.python.distributions import uniform
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 11 for calling the SampleDistributionTest obj's underlying member method code with example usage: obj.test_variable_shape_change() without return types