# Buggy code
def _merge_with(
    self,
    *others: Union["BaseContainer", Dict[str, Any], List[Any], Tuple[Any], Any],
) -> None:
    from .dictconfig import DictConfig
    from .listconfig import ListConfig
    from .omegaconf import OmegaConf

    """merge a list of other Config objects into this one, overriding as needed"""
    for other in others:
        if other is None:
            raise ValueError("Cannot merge with a None config")

        my_flags = {}
        if self._get_flag("allow_objects") is True:
            my_flags = {"allow_objects": True}
        other = _ensure_container(other, flags=my_flags)

        if isinstance(self, DictConfig) and isinstance(other, DictConfig):
            BaseContainer._map_merge(self, other)
        elif isinstance(self, ListConfig) and isinstance(other, ListConfig):
            if self._is_none() or self._is_missing() or self._is_interpolation():
                self.__dict__["_content"] = []
            else:
                self.__dict__["_content"].clear()

            if other._is_missing():
                self._set_value("???")
            elif other._is_none():
                self._set_value(None)
            else:
                et = self._metadata.element_type
                if is_structured_config(et):
                    prototype = OmegaConf.structured(et)
                    for item in other:
                        if isinstance(item, DictConfig):
                            item = OmegaConf.merge(prototype, item)
                        self.append(item)

                else:
                    for item in other:
                        self.append(item)

            # explicit flags on the source config are replacing the flag values in the destination
            flags = other._metadata.flags
            assert flags is not None
            for flag, value in flags.items():
                if value is not None:
                    self._set_flag(flag, value)
        else:
            raise TypeError("Cannot merge DictConfig with ListConfig")

    # recursively correct the parent hierarchy after the merge
    self._re_parent()


# Traceback (omegaconf.errors.ConfigKeyError)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/private/home/abaevski/.conda/envs/fairseq-fp16-20200821/lib/python3.6/site-packages/omegaconf/omegaconf.py", line 321, in merge
target.merge_with(*others[1:])
File "/private/home/abaevski/.conda/envs/fairseq-fp16-20200821/lib/python3.6/site-packages/omegaconf/basecontainer.py", line 327, in merge_with
self._format_and_raise(key=None, value=None, cause=e)
File "/private/home/abaevski/.conda/envs/fairseq-fp16-20200821/lib/python3.6/site-packages/omegaconf/base.py", line 101, in _format_and_raise
type_override=type_override,
File "/private/home/abaevski/.conda/envs/fairseq-fp16-20200821/lib/python3.6/site-packages/omegaconf/_utils.py", line 675, in format_and_raise
_raise(ex, cause)
File "/private/home/abaevski/.conda/envs/fairseq-fp16-20200821/lib/python3.6/site-packages/omegaconf/_utils.py", line 591, in _raise
raise ex  # set end OC_CAUSE=1 for full backtrace
omegaconf.errors.ConfigKeyError: str interpolation key 'optimization.lr' not found
full_key:
reference_type=Any
object_type=test_class

# Fixed code
def _merge_with(
    self,
    *others: Union["BaseContainer", Dict[str, Any], List[Any], Tuple[Any], Any],
) -> None:
    from .dictconfig import DictConfig
    from .listconfig import ListConfig
    from .omegaconf import OmegaConf

    """merge a list of other Config objects into this one, overriding as needed"""
    for other in others:
        if other is None:
            raise ValueError("Cannot merge with a None config")

        my_flags = {}
        if self._get_flag("allow_objects") is True:
            my_flags = {"allow_objects": True}
        other = _ensure_container(other, flags=my_flags)

        if isinstance(self, DictConfig) and isinstance(other, DictConfig):
            BaseContainer._map_merge(self, other)
        elif isinstance(self, ListConfig) and isinstance(other, ListConfig):
            self.__dict__["_content"] = []

            if other._is_interpolation():
                self._set_value(other._value())
            elif other._is_missing():
                self._set_value("???")
            elif other._is_none():
                self._set_value(None)
            else:
                et = self._metadata.element_type
                if is_structured_config(et):
                    prototype = OmegaConf.structured(et)
                    for item in other:
                        if isinstance(item, DictConfig):
                            item = OmegaConf.merge(prototype, item)
                        self.append(item)

                else:
                    for item in other:
                        self.append(item)

            # explicit flags on the source config are replacing the flag values in the destination
            flags = other._metadata.flags
            assert flags is not None
            for flag, value in flags.items():
                if value is not None:
                    self._set_flag(flag, value)
        else:
            raise TypeError("Cannot merge DictConfig with ListConfig")

    # recursively correct the parent hierarchy after the merge
    self._re_parent()