code: def as_simple_encoder(encoder, tensorspec):
      """Wraps an `Encoder` object as a `SimpleEncoder`.
  
      Args:
        encoder: An `Encoder` object to be used to encoding.
        tensorspec: A `TensorSpec`. The created `SimpleEncoder` will be constrained
          to only encode input values compatible with `tensorspec`.
  
      Returns:
        A `SimpleEncoder`.
  
      Raises:
        TypeError:
          If `encoder` is not an `Encoder` or `tensorspec` is not a `TensorSpec`.
      """
      if not isinstance(encoder, core_encoder.Encoder):
          raise TypeError(
              "The encoder must be an instance of `Encoder`."
          )
      if not isinstance(tensorspec, tf.TensorSpec):
          raise TypeError("The tensorspec must be a tf.TensorSpec.")
      return simple_encoder.SimpleEncoder(encoder, tensorspec)
  
file_path: model-optimization/tensorflow_model_optimization/python/core/internal/tensor_encoding/encoders/common_encoders.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  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 gather_encoder
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.core import simple_encoder
  from tensorflow_model_optimization.python.core.internal.tensor_encoding.stages import stages_impl
label_desc: Use image node_id 1 for calling a global function with example usage: as_simple_encoder(encoder, tensorspec) and returns: simple_encoder