def _wrap(cls: Type[_BaseEncoderVar]) -> Type[_BaseEncoderVar]:
    """Decorator inner wrapper needed to support `name` argument."""
    if not issubclass(cls, base_encoder.BaseEncoder):
      raise TypeError(
          'Invalid encoder. Encoder %s does not subclass BaseEncoder.' %
          cls.__name__)

    if name in _ENCODER_REGISTRY:
      raise ValueError(
          'Encoder name %s has already been registered with class %s' %
          (name, _ENCODER_REGISTRY[name].__name__))

    _ENCODER_REGISTRY[name] = cls

    return cls
Decorator inner wrapper needed to support `name` argument.
language/mentionmemory/encoders/encoder_registry.py