docstr: Tests functionality with a general, composite `Encoder`.
docstr_tok: ["Tests","functionality","with","a","general",",","composite","`","Encoder","`","."]
code: def test_composite_encoder(self):
      """Tests functionality with a general, composite `Encoder`."""
      x_fn = lambda: tf.constant(1.2)
      encoder = core_encoder.EncoderComposer(
          test_utils.SignIntFloatEncodingStage()
      )
      encoder.add_child(test_utils.TimesTwoEncodingStage(), SIF_SIGNS)
      encoder.add_child(test_utils.PlusOneEncodingStage(), SIF_INTS)
      encoder.add_child(
          test_utils.TimesTwoEncodingStage(), SIF_FLOATS
      ).add_child(test_utils.PlusOneOverNEncodingStage(), T2_VALS)
      encoder = gather_encoder.GatherEncoder.from_encoder(
          encoder.make(), tf.TensorSpec.from_tensor(x_fn())
      )
  
      num_summands = 3
      iteration = _make_iteration_function(encoder, x_fn, num_summands)
      state = encoder.initial_state()
  
      for i in range(1, 5):
          data = self.evaluate(iteration(state))
          for j in range(num_summands):
              self.assertAllClose(
                  2.0,
                  _encoded_x_field(
                      data.encoded_x[j], [TENSORS, SIF_SIGNS, T2_VALS]
                  ),
              )
              self.assertAllClose(
                  2.0,
                  _encoded_x_field(
                      data.encoded_x[j], [TENSORS, SIF_INTS, P1_VALS]
                  ),
              )
              self.assertAllClose(
                  0.4 + 1 / i,
                  _encoded_x_field(
                      data.encoded_x[j],
                      [TENSORS, SIF_FLOATS, T2_VALS, PN_VALS],
                  ),
              )
              self.assertAllClose(data.x[j], data.part_decoded_x[j])
              self.assertAllClose(
                  data.x[j] * num_summands, data.summed_part_decoded_x
              )
              self.assertAllClose(
                  data.x[j] * num_summands, data.decoded_x
              )
  
          self.assertEqual((i,), data.initial_state)
          self.assertEqual((i + 1,), data.updated_state)
          state = data.updated_state
  
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 the GatherEncoderTest obj's underlying member method code with example usage: obj.test_composite_encoder() without return types