def METHOD_NAME(params, *args):
    """Get optimizer."""
    learning_rate = learning_rate_schedule(params, *args)
    if params["optimizer"].lower() == "sgd":
        logging.info("Use SGD optimizer")
        optimizer = tf.keras.optimizers.legacy.SGD(learning_rate, momentum=params["momentum"])
    elif params["optimizer"].lower() == "adam":
        logging.info("Use Adam optimizer")
        optimizer = tf.keras.optimizers.legacy.Adam(learning_rate)
    else:
        raise ValueError("optimizers should be adam or sgd")
    return optimizer