def METHOD_NAME(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)