code: def _inside_contraction_fn(
      objective_function,
      simplex,
      objective_values,
      face_centroid,
      best_index,
      worst_index,
      worst_objective_value,
      contraction,
      shrinkage,
      batch_evaluate_objective,
  ):
      """Creates the condition function pair for an inside contraction."""
  
      def _contraction():
          """Performs a contraction."""
          contracted = face_centroid - contraction * (
              face_centroid - simplex[worst_index]
          )
          objective_at_contracted = objective_function(contracted)
          is_contracted_acceptable = (
              objective_at_contracted <= worst_objective_value
          )
  
          def _accept_contraction():
              next_simplex = _replace_at_index(
                  simplex, worst_index, contracted
              )
              objective_at_next_simplex = _replace_at_index(
                  objective_values, worst_index, objective_at_contracted
              )
              return (
                  False,
                  next_simplex,
                  objective_at_next_simplex,
                  np.int32(1),
              )
  
          def _reject_contraction():
              return _shrink_towards_best(
                  objective_function,
                  simplex,
                  best_index,
                  shrinkage,
                  batch_evaluate_objective,
              )
  
          return ps.cond(
              is_contracted_acceptable,
              _accept_contraction,
              _reject_contraction,
          )
  
      return _contraction
  
imports: import collections
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensorshape_util
label_desc: Use image node_id 6 for calling a global function with example usage: _inside_contraction_fn(objective_function, simplex, objective_values, face_centroid, best_index, worst_index, worst_objective_value, contraction, shrinkage, batch_evaluate_objective) and returns: _contraction, ps, False,  next_simplex,  objective_at_next_simplex,  np, _shrink_towards_best