(param)
Examples:

        1. "early_stop": "diff"
        2. "early_stop": {
                "early_stop": "diff",
                "eps": 0.0001
            }
Examples:
Examples :
def _parse_early_stop(param):
    """
    Examples:

        1. "early_stop": "diff"
        2. "early_stop": {
                "early_stop": "diff",
                "eps": 0.0001
            }
    """
    default_eps = 0.0001
    if isinstance(param, str):
        return SimpleNamespace(converge_func=param, eps=default_eps)
    elif isinstance(param, dict):
        early_stop = param.get("early_stop", param.get("converge_func"))
        eps = param.get("eps", default_eps)
        if not early_stop:
            raise ValueError(f"early_stop config: {param} invalid")
        return SimpleNamespace(converge_func=early_stop, eps=eps)
    else:
        raise ValueError(f"invalid type for early_stop: {type(param)}")
def _parse_early_stop ( param ) : default_eps = 0.0001 if isinstance ( param , str ) : return SimpleNamespace ( converge_func = param , eps = default_eps ) elif isinstance ( param , dict ) : early_stop = param . get ( "early_stop" , param . get ( "converge_func" ) ) eps = param . get ( "eps" , default_eps ) if not early_stop : raise ValueError ( f"early_stop config: {param} invalid" ) return SimpleNamespace ( converge_func = early_stop , eps = eps ) else : raise ValueError ( f"invalid type for early_stop: {type(param)}" )