(opt)
Examples:

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

            1. "optimize": "SGD"
            2. "optimize": {
                "optimizer": "SGD",
                "learning_rate": 0.05
            }
        """

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