code: def testProb(self):
      # Generate some positive definite (pd) matrices and their Cholesky
      # factorizations.
      x = np.array(
          [
              make_pd(1.0, 2),
              make_pd(2.0, 2),
              make_pd(3.0, 2),
              make_pd(4.0, 2),
          ]
      )
      chol_x = np.array(
          [chol(x[0]), chol(x[1]), chol(x[2]), chol(x[3])]
      )
  
      # Since Wishart wasn't added to SciPy until 0.16, we'll spot check some
      # pdfs with hard-coded results from upstream SciPy.
  
      log_prob_df_seq = np.array(
          [
              # math.log(stats.wishart.pdf(x[0], df=2+0, scale=x[0]))
              -3.5310242469692907,
              # math.log(stats.wishart.pdf(x[1], df=2+1, scale=x[1]))
              -7.689907330328961,
              # math.log(stats.wishart.pdf(x[2], df=2+2, scale=x[2]))
              -10.815845159537895,
              # math.log(stats.wishart.pdf(x[3], df=2+3, scale=x[3]))
              -13.640549882916691,
          ]
      )
  
      # This test checks that batches don't interfere with correctness.
      w = wishart.WishartTriL(
          df=[2, 3, 4, 5],
          scale_tril=chol_x,
          input_output_cholesky=True,
          validate_args=True,
      )
      self.assertAllClose(
          log_prob_df_seq, self.evaluate(w.log_prob(chol_x))
      )
  
      # Now we test various constructions of Wishart with different sample
      # shape.
  
      log_prob = np.array(
          [
              # math.log(stats.wishart.pdf(x[0], df=4, scale=x[0]))
              -4.224171427529236,
              # math.log(stats.wishart.pdf(x[1], df=4, scale=x[0]))
              -6.3378770664093453,
              # math.log(stats.wishart.pdf(x[2], df=4, scale=x[0]))
              -12.026946850193017,
              # math.log(stats.wishart.pdf(x[3], df=4, scale=x[0]))
              -20.951582705289454,
          ]
      )
  
      w = wishart.WishartTriL(
          df=4,
          scale_tril=chol_x[0],
          input_output_cholesky=False,
          validate_args=True,
      )
      dimension = w.scale.domain_dimension_tensor()
      self.assertAllEqual((2, 2), self.evaluate(w.event_shape_tensor()))
      self.assertEqual(2, self.evaluate(dimension))
      self.assertAllClose(log_prob[0], self.evaluate(w.log_prob(x[0])))
      self.assertAllClose(
          log_prob[0:2], self.evaluate(w.log_prob(x[0:2]))
      )
      self.assertAllClose(
          np.reshape(log_prob, (2, 2)),
          self.evaluate(w.log_prob(np.reshape(x, (2, 2, 2, 2)))),
      )
      self.assertAllClose(
          np.reshape(np.exp(log_prob), (2, 2)),
          self.evaluate(w.prob(np.reshape(x, (2, 2, 2, 2)))),
      )
      self.assertAllEqual(
          (2, 2), w.log_prob(np.reshape(x, (2, 2, 2, 2))).shape
      )
  
      w = wishart.WishartTriL(
          df=4,
          scale_tril=chol_x[0],
          input_output_cholesky=True,
          validate_args=True,
      )
      dimension = w.scale.domain_dimension_tensor()
      self.assertAllEqual((2, 2), self.evaluate(w.event_shape_tensor()))
      self.assertEqual(2, self.evaluate(dimension))
      self.assertAllClose(
          log_prob[0], self.evaluate(w.log_prob(chol_x[0]))
      )
      self.assertAllClose(
          log_prob[0:2], self.evaluate(w.log_prob(chol_x[0:2]))
      )
      self.assertAllClose(
          np.reshape(log_prob, (2, 2)),
          self.evaluate(w.log_prob(np.reshape(chol_x, (2, 2, 2, 2)))),
      )
      self.assertAllClose(
          np.reshape(np.exp(log_prob), (2, 2)),
          self.evaluate(w.prob(np.reshape(chol_x, (2, 2, 2, 2)))),
      )
      self.assertAllEqual(
          (2, 2), w.log_prob(np.reshape(x, (2, 2, 2, 2))).shape
      )
  
imports: import numpy
  from scipy import linalg
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import mixture_same_family
  from tensorflow_probability.python.distributions import wishart
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 15 for calling the WishartTest obj's underlying member method code with example usage: obj.testProb() without return types