def METHOD_NAME(name):
    """Returns the optimizer class.
    Args:
      name: The optimizer name.
    Returns:
      A class extending ``tf.keras.optimizers.legacy.Optimizer``.
    Raises:
      ValueError: if :obj:`name` can not be resolved to an optimizer class.
    """
    optimizer_class = None
    if optimizer_class is None:
        optimizer_class = getattr(tf_optimizers, name, None)
    if optimizer_class is None:
        optimizer_class = getattr(tfa.optimizers, name, None)
    if optimizer_class is None:
        optimizer_class = _OPTIMIZERS_REGISTRY.get(name)
    if optimizer_class is None:
        raise ValueError("Unknown optimizer class: %s" % name)
    return optimizer_class