code: def merge_configs(*configs, differentiators=("type",)):
      """Merge configuration dictionaries following the given hierarchy
  
      Suppose function is called as merge_configs(A, B, C). Then any pair (key, value) in C would
      overwrite any previous value from A or B. Same apply for B over A.
  
      If for some pair (key, value), the value is a dictionary, then it will either overwrite previous
      value if it was not also a directory, or it will be merged following
      `merge_configs(old_value, new_value)`.
  
      .. warning:
  
          Redefinition of subdictionaries may lead to confusing results because merges do not remove
          data.
  
          If for instance, we have {'a': {'b': 1, 'c': 2}} and we would like to update `'a'` such that
          it only have `{'c': 3}`, it won't work with {'a': {'c': 3}}.
  
          merge_configs({'a': {'b': 1, 'c': 2}}, {'a': {'c': 3}}) -> {'a': {'b': 1, 'c': 3}}
  
      Examples
      --------
      .. code-block:: python
          :linenos:
  
          a = {'a': 1, 'b': {'c': 2}}
          b = {'b': {'c': 3}}
          c = {'b': {'c': {'d': 4}}}
  
          m = resolve_config.merge_configs(a, b, c)
  
          assert m == {'a': 1, 'b': {'c': {'d': 4}}}
  
          a = {'a': 1, 'b': {'c': 2, 'd': 3}}
          b = {'b': {'c': 4}}
          c = {'b': {'c': {'e': 5}}}
  
          m = resolve_config.merge_configs(a, b, c)
  
          assert m == {'a': 1, 'b': {'c': {'e': 5}, 'd': 3}}
  
      """
      merged_config = configs[0]
  
      def _can_be_merged(dict_a, dict_b):
          for differentiator in differentiators:
              if dict_a.get(differentiator, None) and dict_a[
                  differentiator
              ] != dict_b.get(differentiator, None):
                  return False
  
          return True
  
      for config_i in configs[1:]:
          for key, value in config_i.items():
              if (
                  isinstance(value, dict)
                  and isinstance(merged_config.get(key), dict)
                  and _can_be_merged(merged_config[key], value)
              ):
                  merged_config[key] = merge_configs(
                      merged_config[key],
                      value,
                      differentiators=differentiators,
                  )
              elif value is not None:
                  merged_config[key] = value
  
      return merged_config
  
imports: import copy
  import getpass
  import hashlib
  import logging
  import os
  import git
  import yaml
  from numpy import inf
  import orion
  import orion.core
  from orion.core.io.orion_cmdline_parser import OrionCmdlineParser
  from orion.core.utils.flatten import unflatten
label_desc: Use image node_id 8 for calling a global function with example usage: merge_configs() and returns: merged_config, True, False