# Buggy code
def _map_merge(dest: "BaseContainer", src: "BaseContainer") -> None:
    """merge src into dest and return a new copy, does not modified input"""
    from omegaconf import DictConfig, OmegaConf, ValueNode

    assert isinstance(dest, DictConfig)
    assert isinstance(src, DictConfig)
    src_type = src._metadata.object_type

    # if source DictConfig is missing set the DictConfig one to be missing too.
    if src._is_missing():
        dest._set_value("???")
        return
    dest._validate_set_merge_impl(key=None, value=src, is_assign=False)

    def expand(node: Container) -> None:
        type_ = get_ref_type(node)
        if type_ is not None:
            _is_optional, type_ = _resolve_optional(type_)
            if is_dict_annotation(type_):
                node._set_value({})
            else:
                node._set_value(type_)

    if dest._is_missing():
        expand(dest)

    for key, src_value in src.items_ex(resolve=False):
        dest_node = dest._get_node(key, validate_access=False)
        if isinstance(dest_node, Container) and OmegaConf.is_none(dest, key):
            if not OmegaConf.is_none(src_value):
                expand(dest_node)

        if dest_node is not None:
            if dest_node._is_interpolation():
                target_node = dest_node._dereference_node(
                    throw_on_resolution_failure=False
                )
                if isinstance(target_node, Container):
                    dest[key] = target_node
                    dest_node = dest._get_node(key)

        if is_structured_config(dest._metadata.element_type):
            dest[key] = DictConfig(content=dest._metadata.element_type, parent=dest)
            dest_node = dest._get_node(key)

        if dest_node is not None:
            if isinstance(dest_node, BaseContainer):
                if isinstance(src_value, BaseContainer):
                    dest._validate_merge(key=key, value=src_value)
                    dest_node._merge_with(src_value)
                else:
                    dest.__setitem__(key, src_value)
            else:
                if isinstance(src_value, BaseContainer):
                    dest.__setitem__(key, src_value)
                else:
                    assert isinstance(dest_node, ValueNode)
                    try:
                        dest_node._set_value(src_value)
                    except (ValidationError, ReadonlyConfigError) as e:
                        dest._format_and_raise(key=key, value=src_value, cause=e)
        else:
            from omegaconf import open_dict

            if is_structured_config(src_type):
                # verified to be compatible above in _validate_set_merge_impl
                with open_dict(dest):
                    dest[key] = src._get_node(key)
            else:
                dest[key] = src._get_node(key)

    if src_type is not None and not is_primitive_dict(src_type):
        dest._metadata.object_type = src_type

    # explicit flags on the source config are replacing the flag values in the destination
    for flag, value in src._metadata.flags.items():
        if value is not None:
            dest._set_flag(flag, value)


# Traceback (omegaconf.errors.ValidationError)
Traceback (most recent call last):
File "hydra/_internal/config_load
er_impl.py", line 610, in _load_config_impl
merged = OmegaConf.merge(schema.config, ret.config)
File "omegaconf/omegaconf.py", li
ne 316, in merge
target.merge_with(*others[1:])
File "omegaconf/basecontainer.py"
, line 324, in merge_with
self._format_and_raise(key=None, value=None, cause=e)
File "omegaconf/base.py", line 10
1, in _format_and_raise
type_override=type_override,
File "omegaconf/_utils.py", line
675, in format_and_raise
_raise(ex, cause)
File "omegaconf/_utils.py", line
591, in _raise
raise ex  # set end OC_CAUSE=1 for full backtrace
omegaconf.errors.ValidationError: Invalid value assigned : _GenericAlias is not a subclass of ListConfig or list.
full_key:
reference_type=Optional[Dict[Union[str, Enum], Any]]
object_type=dict

The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "hydra/_internal/utils.py",
line 203, in run_and_report
return func()
File "hydra/_internal/utils.py",
line 355, in <lambda>
overrides=args.overrides,
File "hydra/_internal/hydra.py",
line 102, in run
run_mode=RunMode.RUN,
File "hydra/_internal/hydra.py",
line 512, in compose_config
from_shell=from_shell,
File "hydra/_internal/config_loader_impl.py", line 153, in load_configuration
from_shell=from_shell,
File "hydra/_internal/config_loader_impl.py", line 256, in _load_configuration
run_mode=run_mode,
File "hydra/_internal/config_loader_impl.py", line 797, in _merge_defaults_into_config
hydra_cfg = merge_defaults_list_into_config(hydra_cfg, user_list)
File "hydra/_internal/config_loader_impl.py", line 775, in merge_defaults_list_into_config
package_override=default1.package,
File "hydra/_internal/config_loader_impl.py", line 690, in _merge_config
package_override=package_override,
File "hydra/_internal/config_loader_impl.py", line 622, in _load_config_impl
) from e
hydra.errors.ConfigCompositionException: Error merging 'lr_scheduler/multi_step' with schema

# Fixed code
def _map_merge(dest: "BaseContainer", src: "BaseContainer") -> None:
    """merge src into dest and return a new copy, does not modified input"""
    from omegaconf import DictConfig, OmegaConf, ValueNode

    assert isinstance(dest, DictConfig)
    assert isinstance(src, DictConfig)
    src_type = src._metadata.object_type

    # if source DictConfig is missing set the DictConfig one to be missing too.
    if src._is_missing():
        dest._set_value("???")
        return
    dest._validate_set_merge_impl(key=None, value=src, is_assign=False)

    def expand(node: Container) -> None:
        type_ = get_ref_type(node)
        if type_ is not None:
            _is_optional, type_ = _resolve_optional(type_)
            if is_dict_annotation(type_):
                node._set_value({})
            elif is_list_annotation(type_):
                node._set_value([])
            else:
                node._set_value(type_)

    if dest._is_missing():
        expand(dest)

    for key, src_value in src.items_ex(resolve=False):
        dest_node = dest._get_node(key, validate_access=False)
        if isinstance(dest_node, Container) and OmegaConf.is_none(dest, key):
            if not OmegaConf.is_none(src_value):
                expand(dest_node)

        if dest_node is not None:
            if dest_node._is_interpolation():
                target_node = dest_node._dereference_node(
                    throw_on_resolution_failure=False
                )
                if isinstance(target_node, Container):
                    dest[key] = target_node
                    dest_node = dest._get_node(key)

        if is_structured_config(dest._metadata.element_type):
            dest[key] = DictConfig(content=dest._metadata.element_type, parent=dest)
            dest_node = dest._get_node(key)

        if dest_node is not None:
            if isinstance(dest_node, BaseContainer):
                if isinstance(src_value, BaseContainer):
                    dest._validate_merge(key=key, value=src_value)
                    dest_node._merge_with(src_value)
                else:
                    dest.__setitem__(key, src_value)
            else:
                if isinstance(src_value, BaseContainer):
                    dest.__setitem__(key, src_value)
                else:
                    assert isinstance(dest_node, ValueNode)
                    try:
                        dest_node._set_value(src_value)
                    except (ValidationError, ReadonlyConfigError) as e:
                        dest._format_and_raise(key=key, value=src_value, cause=e)
        else:
            from omegaconf import open_dict

            if is_structured_config(src_type):
                # verified to be compatible above in _validate_set_merge_impl
                with open_dict(dest):
                    dest[key] = src._get_node(key)
            else:
                dest[key] = src._get_node(key)

    if src_type is not None and not is_primitive_dict(src_type):
        dest._metadata.object_type = src_type

    # explicit flags on the source config are replacing the flag values in the destination
    for flag, value in src._metadata.flags.items():
        if value is not None:
            dest._set_flag(flag, value)