code: def flatten_dict(x):
      
      out = {}
      for k, v in x.items():
          out = _recur_flatten(k, v, out)
      return out
docs: Flatten a dict
      
      Flatten an arbitrarily nested dict as output by to_dict
      
      .. note:: 
      
          Keys in the flattened dict may get very long. 
          
      Args:
          x (dict): Arbitrarily nested dict (maybe resembling a tree) with literal/scalar leaf values
      
      Returns:
          dict: flattened 1D dict