def METHOD_NAME(cls, predictions):
    if isinstance(predictions, list) and not predictions:
        raise ValueError("The input list is empty")
    if isinstance(predictions, dict):
        if "candidates" not in predictions and len(predictions) > 1:
            raise ValueError(
                "The dict format is invalid for this route type. Ensure the served model "
                "returns a dict key containing 'candidates'"
            )
        if len(predictions) == 1:
            predictions = next(iter(predictions.values()))
        else:
            predictions = predictions.get("candidates", predictions)
        if not predictions:
            raise ValueError("The input list is empty")
    return predictions