(param)
Examples:

        1. "optimize": "SGD"
        2. "optimize": {
                "optimizer": "SGD",
                "learning_rate": 0.05
            }
Examples:
Examples :
def _parse_optimizer(param):
    """
    Examples:

        1. "optimize": "SGD"
        2. "optimize": {
                "optimizer": "SGD",
                "learning_rate": 0.05
            }
    """
    kwargs = {}
    if isinstance(param, str):
        return SimpleNamespace(optimizer=param, kwargs=kwargs)
    elif isinstance(param, dict):
        optimizer = param.get("optimizer", kwargs)
        if not optimizer:
            raise ValueError(f"optimizer config: {param} invalid")
        kwargs = {k: v for k, v in param.items() if k != "optimizer"}
        return SimpleNamespace(optimizer=optimizer, kwargs=kwargs)
    else:
        raise ValueError(f"invalid type for optimize: {type(param)}")
def _parse_optimizer ( param ) : kwargs = { } if isinstance ( param , str ) : return SimpleNamespace ( optimizer = param , kwargs = kwargs ) elif isinstance ( param , dict ) : optimizer = param . get ( "optimizer" , kwargs ) if not optimizer : raise ValueError ( f"optimizer config: {param} invalid" ) kwargs = { k : v for k , v in param . items ( ) if k != "optimizer" } return SimpleNamespace ( optimizer = optimizer , kwargs = kwargs ) else : raise ValueError ( f"invalid type for optimize: {type(param)}" )