<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register_macro(name: str, func: Callable, allow_overwrite: bool = False) -> None: """Register new macro to Circuit. Args: name (str):
 The name of macro. func (callable):
 The function to be called. allow_overwrite (bool, optional):
 If True, allow to overwrite the existing macro. Otherwise, raise the ValueError. Raises: ValueError: The name is duplicated with existing macro, gate or method. When `allow_overwrite=True`, this error is not raised. """

        if hasattr(Circuit, name):
            if allow_overwrite:
                warnings.warn(f"Circuit has attribute `{name}`.")
            else:
                raise ValueError(f"Circuit has attribute `{name}`.")
        if name.startswith("run_with_"):
            if allow_overwrite:
                warnings.warn(f"Gate name `{name}` may conflict with run of backend.")
            else:
                raise ValueError(f"Gate name `{name}` shall not start with 'run_with_'.")
        if not allow_overwrite:
            if name in GATE_SET:
                raise ValueError(f"Gate '{name}' is already exists in gate set.")
            if name in GLOBAL_MACROS:
                raise ValueError(f"Macro '{name}' is already exists.")
        GLOBAL_MACROS[name] = func