code: def generalized_paretos(draw, batch_shape=None):
      if batch_shape is None:
          batch_shape = draw(tfp_hps.shapes())
  
      constraints = dict(
          loc=tfp_hps.identity_fn,
          scale=tfp_hps.softplus_plus_eps(),
          concentration=lambda x: tf.math.tanh(x) * 0.24,
      )  # <.25==safe for variance
  
      params = draw(
          tfp_hps.broadcasting_params(
              batch_shape,
              params_event_ndims=dict(loc=0, scale=0, concentration=0),
              constraint_fn_for=constraints.get,
          )
      )
      dist = gp.GeneralizedPareto(
          validate_args=draw(hps.booleans()), **params
      )
      if dist.batch_shape != batch_shape:
          raise AssertionError(
              "batch_shape mismatch: expect {} but got {}".format(
                  batch_shape, dist
              )
          )
      return dist
  
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 1 for calling a global function with example usage: generalized_paretos(draw, batch_shape) and returns: dist