code: def _check_convergence(
      population, population_values, func_tolerance, position_tolerance
  ):
      """Checks whether the convergence criteria have been met."""
      # Check func tolerance
      value_range = tf.math.abs(
          tf.math.reduce_max(population_values)
          - tf.math.reduce_min(population_values)
      )
      value_converged = value_range <= func_tolerance
      # Ideally, we would compute the position convergence by computing the
      # pairwise distance between every member of the population and checking if
      # the maximum of those is less than the supplied tolerance. However, this is
      # completely infeasible in terms of performance. We adopt a more conservative
      # approach which checks the distance between the first population member
      # with the rest of the population. If the largest such distance is less than
      # half the supplied tolerance, we stop. The reason why this is sufficient is
      # as follows. For any pair of distinct points (a, b) in the population, we
      # have the relation:  |a - b| <= |x0 - a| + |x0 - b|, where x0 is any
      # other point. In particular, let x0 be the first element of the population
      # and suppose that the largest distance between this point and any other
      # member is epsilon. Then, for any pair of points (a, b),
      # |a - b| <= 2 * epsilon and hence, the maximum distance between any pair of
      # points in the population is bounded above by twice the distance between
      # the first point and other points.
      half_tol = position_tolerance / 2
  
      def part_converged(part):
          return (
              tf.math.reduce_max(tf.math.abs(part - part[0]))
              <= half_tol
          )
  
      x_converged = tf.math.reduce_all(
          [part_converged(part) for part in population]
      )
      return value_converged | x_converged
  
imports: import collections
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.util import seed_stream
label_desc: Use image node_id 6 for calling a global function with example usage: _check_convergence(population, population_values, func_tolerance, position_tolerance) and returns: unknown, unknown