code: def unflatten(flat_dict, encodings=None):
      """Converts a flat dict of key-value pairs to a spec tree.
  
      Example
      -------
          unflatten({
            foo_bar_baz: 123,
            foo_bar_biz: 456,
            x_bonks: 'hi',
          }, ['x'])
  
          # Returns:
          # {
          #   foo: {
          #     bar: {
          #       baz: 123,
          #       biz: 456,
          #     },
          #   },
          #   encoding: {  # This gets added automatically
          #     x: {
          #       bonks: 'hi'
          #     }
          #   }
          # }
  
      Args
      ----
      flat_dict: dict
          A flat dict where keys are fully-qualified paths separated by
          underscores.
  
      encodings: set
          Key names that should be automatically moved into the 'encoding' key.
  
      Returns
      -------
      A tree made of dicts inside of dicts.
      """
      if encodings is None:
          encodings = set()
  
      out_dict = _unflatten_single_dict(flat_dict)
  
      for k, v in list(out_dict.items()):
          # Unflatten child dicts:
          if isinstance(v, dict):
              v = unflatten(v, encodings)
          elif hasattr(v, "__iter__"):
              for i, child in enumerate(v):
                  if isinstance(child, dict):
                      v[i] = unflatten(child, encodings)
  
          # Move items into 'encoding' if needed:
          if k in encodings:
              if "encoding" not in out_dict:
                  out_dict["encoding"] = dict()
              out_dict["encoding"][k] = v
              out_dict.pop(k)
  
      return out_dict
  
imports: from typing import Any, Dict, Mapping, Optional
label_desc: Use image node_id 2 for calling a global function with example usage: unflatten(flat_dict, encodings) and returns: out_dict