def model_max_length(config):
    """Returns the maximum generation length for the given model."""
    return getattr(config, "n_positions", None) or getattr(
        config, "max_position_embeddings", None
    )