code: def with_fallback(preferred, fallback):
      """
      Deep merge two dicts, preferring values from `preferred`.
      """
      preferred_keys = set(preferred.keys())
      fallback_keys = set(fallback.keys())
      common_keys = preferred_keys & fallback_keys
  
      merged = {}
  
      for key in preferred_keys - fallback_keys:
          merged[key] = copy.deepcopy(preferred[key])
      for key in fallback_keys - preferred_keys:
          merged[key] = copy.deepcopy(fallback[key])
  
      for key in common_keys:
          preferred_value = preferred[key]
          fallback_value = fallback[key]
  
          if isinstance(preferred_value, dict) and isinstance(
              fallback_value, dict
          ):
              merged[key] = with_fallback(
                  preferred_value, fallback_value
              )
          else:
              merged[key] = copy.deepcopy(preferred_value)
  
      return merged
  
imports: from __future__ import with_statement
  from __future__ import absolute_import
  from collections import MutableMapping, OrderedDict
  import copy
  import json
  import logging
  import os
  from io import open
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.file_utils import cached_path
label_desc: Use image node_id 2 for calling a global function with example usage: with_fallback(preferred, fallback) and returns: merged