code: def test_custom_weights_prior(self):
      batch_shape = [4, 3]
      num_timesteps = 10
      num_features = 2
      design_matrix = self._build_placeholder(
          np.random.randn(
              *(batch_shape + [num_timesteps, num_features])
          )
      )
  
      # Build a model with scalar Exponential(1.) prior.
      linear_regression = LinearRegression(
          design_matrix=design_matrix,
          weights_prior=exponential.Exponential(
              rate=self._build_placeholder(np.ones(batch_shape))
          ),
      )
  
      # Check that the prior is broadcast to match the shape of the weights.
      weights = linear_regression.parameters[0]
      self.assertAllEqual(
          [num_features],
          self.evaluate(weights.prior.event_shape_tensor()),
      )
      self.assertAllEqual(
          batch_shape, self.evaluate(weights.prior.batch_shape_tensor())
      )
  
      seed = test_util.test_seed(sampler_type="stateless")
      (
          weights_seed,
          ssm_seed,
          shape_seed,
          sample_seed,
      ) = samplers.split_seed(seed, n=4)
      prior_sampled_weights = weights.prior.sample(seed=weights_seed)
      ssm = linear_regression.make_state_space_model(
          num_timesteps=num_timesteps,
          param_vals={"weights": prior_sampled_weights},
      )
  
      lp = ssm.log_prob(ssm.sample(seed=ssm_seed))
      self.assertAllEqual(batch_shape, self.evaluate(lp).shape)
  
      # Verify that the bijector enforces the prior constraint that
      # weights must be nonnegative.
      self.assertAllFinite(
          self.evaluate(
              weights.prior.log_prob(
                  weights.bijector(
                      tf.random.stateless_normal(
                          tf.shape(
                              weights.prior.sample(64, seed=shape_seed)
                          ),
                          seed=sample_seed,
                          dtype=self.dtype,
                      )
                  )
              )
          )
      )
  
imports: import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import cauchy
  from tensorflow_probability.python.distributions import exponential
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import lognormal
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.sts.components.regression import LinearRegression
  from tensorflow_probability.python.sts.components.regression import SparseLinearRegression
  from tensorflow_probability.python.sts.components.sum import Sum
label_desc: Use image node_id 3 for calling the _LinearRegressionTest obj's underlying member method code with example usage: obj.test_custom_weights_prior() without return types