code: def unflatten(flat_dict):
      """
      Given a "flattened" dict with compound keys, e.g.
          {"a.b": 0}
      unflatten it:
          {"a": {"b": 0}}
      """
      unflat = {}
  
      for compound_key, value in list(flat_dict.items()):
          curr_dict = unflat
          parts = compound_key.split(".")
          for key in parts[:-1]:
              curr_value = curr_dict.get(key)
              if key not in curr_dict:
                  curr_dict[key] = {}
                  curr_dict = curr_dict[key]
              elif isinstance(curr_value, dict):
                  curr_dict = curr_value
              else:
                  raise ConfigurationError(
                      "flattened dictionary is invalid"
                  )
          if not isinstance(curr_dict, dict) or parts[-1] in curr_dict:
              raise ConfigurationError(
                  "flattened dictionary is invalid"
              )
          else:
              curr_dict[parts[-1]] = value
  
      return unflat
  
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 1 for calling a global function with example usage: unflatten(flat_dict) and returns: unflat