code: def testVariance(self, dist):
      loc, scale, conc = self.evaluate(
          [dist.loc, dist.scale, dist.concentration]
      )
      # scipy doesn't seem to be very accurate for small concentrations, so use
      # higher precision.
      expected = sp_stats.genpareto(
          np.float64(conc), loc=np.float64(loc), scale=np.float64(scale)
      ).var()
      # scipy sometimes returns nonsense zero or negative variances.
      hp.assume(expected > 0)
      # scipy gets bad answers for very small concentrations even in 64-bit.
      # https://github.com/scipy/scipy/issues/11168
      hp.assume(conc > 1e-4)
      self.assertEqual(dist.batch_shape, dist.variance().shape)
      actual = self.evaluate(dist.variance())
      msg = (
          "Location: {}, scale: {}, concentration: {}, "
          "scipy variance: {}, tfp variance: {}"
      )
      hp.note(msg.format(loc, scale, conc, expected, actual))
      self.assertAllClose(expected, actual)
  
imports: import hypothesis
  import hypothesis.strategies
  import numpy
  from scipy import stats
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import generalized_pareto
  from tensorflow_probability.python.internal import hypothesis_testlib
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 8 for calling the GeneralizedParetoTest obj's underlying member method code with example usage: obj.testVariance(dist) without return types