class_docstr: Class for composing individual encoding stages.
  
  This class provides functionality for arbitrarily composing individual
  encoding stages (implementations of `EncodingStageInterface` or
  `AdaptiveEncodingStageInterface`) into a tree, where an output `Tensor` of an
  encoding stage can be further encoded by another encoding stage.
  
  The interface is similar to that of `AdaptiveEncodingStageInterface`, with the
  additional methods `decode_before_sum` and `decode_after_sum`. These methods
  split the decoding functionality to two parts, based on commutativity with
  summation.
  
  Similar to the `AdaptiveEncodingStageInterface`, the methods are designed to
  be functional transformations. That means, for instance, that the
  `initial_state` and `update_state` methods do not modify any underlying state.
  Rather, the user of the `Encoder` class is responsible for storing any values
  if necessary, and providing them back to appropriate methods of this class.
docstr: Implementation for the `encode` method.
docstr_tok: ["Implementation","for","the","`","encode","`","method","."]
code: def _encode_impl(self, x, encode_params):
      """Implementation for the `encode` method."""
      encoded_tensors = {}
      state_update_tensors = {}
      input_shapes = {}
      if self.stage.decode_needs_input_shape:
          input_shapes[
              EncoderKeys.SHAPE
          ] = py_utils.static_or_dynamic_shape(x)
      else:
          input_shapes[EncoderKeys.SHAPE] = None
      (
          encoded_tensors,
          state_update_tensors[EncoderKeys.TENSORS],
      ) = self.stage.encode(x, encode_params[EncoderKeys.PARAMS])
      children_state_update_tensors = {}
      children_shapes = {}
      for key, encoder in six.iteritems(self.children):
          with tf.compat.v1.name_scope(
              None, "/".join([self.stage.name, key])
          ):
              (
                  encoded_tensors[key],
                  children_state_update_tensors[key],
                  children_shapes[key],
              ) = encoder._encode_impl(  # pylint: disable=protected-access
                  encoded_tensors[key],
                  encode_params[EncoderKeys.CHILDREN][key],
              )
      state_update_tensors[
          EncoderKeys.CHILDREN
      ] = children_state_update_tensors
      input_shapes[EncoderKeys.CHILDREN] = children_shapes
      return encoded_tensors, state_update_tensors, input_shapes
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import six
  import tensorflow
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.core import encoding_stage
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.utils import py_utils
label_desc: Use image node_id 13 for calling the Encoder obj's underlying member method code with example usage: obj._encode_impl(x, encode_params) and returns: encoded_tensors,  state_update_tensors,  input_shapes