def unflatten_dict(flat_dict):
  """Convert a flattened dict to a nested dict.

  Inverse of flatten_config.

  Args:
    flat_dict: A dictionary to unflatten.

  Returns:
    A dictionary with all keys containing `.` split into nested dicts.
    {'a.b.c': 1} --> {'a': {'b': {'c': 1}}}
  """
  result = {}
  for key, val in flat_dict.iteritems():
    parts = key.split('.')
    cur = result
    for part in parts[:-1]:
      if part not in cur:
        cur[part] = {}
      cur = cur[part]
    cur[parts[-1]] = val
  return result