code: def effective_sample_size(x, **kwargs):
      """tfp.mcmc.effective_sample_size, with a maximum appropriate for HMC."""
      # Since ESS is an estimate, it can go wrong...  E.g. we can have negatively
      # correlated samples, which *do* have ESS > N, but this ESS is only applicable
      # for variance reduction power for estimation of the mean.  We want to
      # (blindly) use ESS everywhere (e.g. variance estimates)....and so...
      ess = diagnostic.effective_sample_size(x, **kwargs)
      n = tf.cast(prefer_static.size0(x), x.dtype)
      return tf.minimum(ess, n)
  
imports: from absl import logging
  from absl.testing import parameterized
  import numpy
  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 mvn_diag
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import test_combinations
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.internal import unnest
  from tensorflow_probability.python.mcmc import diagnostic
  from tensorflow_probability.python.mcmc import hmc
  from tensorflow_probability.python.mcmc import random_walk_metropolis
  from tensorflow_probability.python.mcmc import replica_exchange_mc
  from tensorflow_probability.python.mcmc import sample
  from tensorflow_probability.python.mcmc import simple_step_size_adaptation
  from tensorflow_probability.python.stats import sample_stats
label_desc: Use image node_id 3 for calling a global function with example usage: effective_sample_size(x) and returns: tf