docstr: Tests that the encoder works as a proper tree, not only a chain.
docstr_tok: ["Tests","that","the","encoder","works","as","a","proper","tree",",","not","only","a","chain","."]
code: def test_tree_encoder(self):
      """Tests that the encoder works as a proper tree, not only a chain."""
      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.PlusOneEncodingStage(), SIF_FLOATS
      ).add_child(test_utils.TimesTwoEncodingStage(), P1_VALS)
      encoder = encoder.make()
  
      x = tf.constant([0.0, 0.1, -0.1, 0.9, -0.9, 1.6, -2.2])
      encode_params, decode_params = encoder.get_params(
          encoder.initial_state()
      )
      encoded_x, _, input_shapes = encoder.encode(x, encode_params)
      decoded_x = encoder.decode(encoded_x, decode_params, input_shapes)
      x, encoded_x, decoded_x = self.evaluate([x, encoded_x, decoded_x])
  
      self.assertAllClose(x, decoded_x)
      expected_encoded_x = {
          SIF_SIGNS: {
              T2_VALS: np.array([0.0, 2.0, -2.0, 2.0, -2.0, 2.0, -2.0])
          },
          SIF_INTS: {
              P1_VALS: np.array([1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 3.0])
          },
          SIF_FLOATS: {
              P1_VALS: {
                  T2_VALS: np.array([2.0, 2.2, 2.2, 3.8, 3.8, 3.2, 2.4])
              }
          },
      }
      self.assertAllClose(expected_encoded_x, encoded_x)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import numpy
  import tensorflow
  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.testing import test_utils
label_desc: Use image node_id 11 for calling the EncoderTest obj's underlying member method code with example usage: obj.test_tree_encoder() without return types