docstr: Tests that splitting decode works as expected with commutes_with_sum.
  
  This test chains three encoding stages, first *does* commute with sum, the
  second *does not*, and third *does*, again. Together, only the first one
  should commute with sum, and the rest should not.
docstr_tok: ["Tests","that","splitting","decode","works","as","expected","with","commutes_with_sum",".","This","test","chains","three","encoding","stages",",","first","*","does","*","commute","with","sum",",","the","second","*","does","not","*",",","and","third","*","does","*",",","again",".","Together",",","only","the","first","one","should","commute","with","sum",",","and","the","rest","should","not","."]
code: def test_decode_split_commutes_with_sum_true_false_true(self):
      """Tests that splitting decode works as expected with commutes_with_sum.
  
      This test chains three encoding stages, first *does* commute with sum, the
      second *does not*, and third *does*, again. Together, only the first one
      should commute with sum, and the rest should not.
      """
      encoder = (
          core_encoder.EncoderComposer(
              test_utils.TimesTwoEncodingStage()
          )
          .add_parent(test_utils.PlusOneEncodingStage(), P1_VALS)
          .add_parent(test_utils.TimesTwoEncodingStage(), T2_VALS)
          .make()
      )
      self.assertFalse(encoder.fully_commutes_with_sum)
      data = self._data_for_test_decode_split(encoder, tf.constant(3.0))
  
      # Test the encoding is as expected.
      self.assertEqual(data.x, data.decoded_x_after_sum)
      self.assertAllEqual(
          {
              T2_VALS: {P1_VALS: {T2_VALS: (data.x * 2.0 + 1.0) * 2.0}},
          },
          data.encoded_x,
      )
      # Only first part commutes with sum.
      self.assertAllEqual(
          {T2_VALS: data.x * 2.0}, data.decoded_x_before_sum
      )
      self.assertEqual(
          {
              COMMUTE: True,
              CHILDREN: {
                  T2_VALS: {
                      COMMUTE: False,
                      CHILDREN: {
                          P1_VALS: {COMMUTE: False, CHILDREN: {}},
                      },
                  }
              },
          },
          encoder.commuting_structure,
      )
  
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 7 for calling the EncoderTest obj's underlying member method code with example usage: obj.test_decode_split_commutes_with_sum_true_false_true() without return types