docstr: Tests basic encoding and decoding works as expected.
docstr_tok: ["Tests","basic","encoding","and","decoding","works","as","expected","."]
code: def test_basic_encode_decode(self):
      """Tests basic encoding and decoding works as expected."""
      x_fn = lambda: tf.random.uniform((12,))
      encoder = gather_encoder.GatherEncoder.from_encoder(
          core_encoder.EncoderComposer(
              test_utils.PlusOneOverNEncodingStage()
          ).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(
                  data.x[j] + 1 / i,
                  _encoded_x_field(
                      data.encoded_x[j], [TENSORS, PN_VALS]
                  ),
              )
          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 1 for calling the GatherEncoderTest obj's underlying member method code with example usage: obj.test_basic_encode_decode() without return types