code: def _make_stateless_iteration_function(encoder, x_fn, num_summands):
      """Returns a tf.function utility for testing, which does not use state."""
  
      assert isinstance(encoder, gather_encoder.GatherEncoder)
  
      @tf.function
      def iteration():
          x = []
          encoded_x = []
          part_decoded_x = []
  
          (
              encode_params,
              decode_before_sum_params,
              decode_after_sum_params,
          ) = encoder.get_params()
          for _ in range(num_summands):
              x_value = x_fn()
              enc_x, _ = encoder.encode(x_value, encode_params)
              part_dec_x = encoder.decode_before_sum(
                  enc_x, decode_before_sum_params
              )
              x.append(x_value)
              encoded_x.append(enc_x)
              part_decoded_x.append(part_dec_x)
  
          summed_part_decoded_x = part_decoded_x[0]
          for addend in part_decoded_x[1:]:
              summed_part_decoded_x = tf.nest.map_structure(
                  lambda x, y: x + y, summed_part_decoded_x, addend
              )
  
          decoded_x = encoder.decode_after_sum(
              summed_part_decoded_x,
              decode_after_sum_params,
              num_summands,
          )
  
          dummy = tf.constant(
              0.0
          )  # Avoids having to separate TF/PY values.
          return TestData(
              x,
              encoded_x,
              part_decoded_x,
              summed_part_decoded_x,
              decoded_x,
              dummy,
              dummy,
          )
  
      return iteration
  
imports: import collections
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow.python.framework import test_util
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.core import core_encoder
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.core import encoding_stage
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.core import gather_encoder
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.testing import test_utils
label_desc: Use image node_id 2 for calling a global function with example usage: _make_stateless_iteration_function(encoder, x_fn, num_summands) and returns: iteration, TestData