code: def convert_cfg_base_to_nested_dictionary(
      cfg: DefaultConfigProblemBase,
  ) -> dict:
      """Returns a grouped config settings dict for a given configuration
  
      Args:
          cfg: configuration
          q: Q
  
      Returns:
          Dict of configuration settings
      """
  
      cfg_dict = cfg.__dict__
      type_annotations = cfg.get_annotations()
      cfg_dict = {key: cfg_dict[key] for key in cfg._get_order()}
  
      grouped_cfg_dict = {}
  
      for k, v in cfg_dict.items():
          if k.startswith("_"):
              continue
  
          if any([x in k for x in ["api", "secret"]]):
              raise AssertionError(
                  "Config item must not contain the word 'api' or 'secret'"
              )
  
          type_annotation = type_annotations[k]
  
          if type_annotation in KNOWN_TYPE_ANNOTATIONS:
              grouped_cfg_dict.update({k: v})
          elif dataclasses.is_dataclass(v):
              group_items = parse_cfg_dataclass(cfg=v)
              group_items = {
                  k: list(v) if isinstance(v, tuple) else v
                  for d in group_items
                  for k, v in d.items()
              }
              grouped_cfg_dict.update({k: group_items})
          else:
              raise _get_type_annotation_error(v, type_annotations[k])
  
      # not an explicit field in the config
      grouped_cfg_dict["problem_type"] = cfg.problem_type
      return grouped_cfg_dict
  
file_path: h2o-llmstudio/llm_studio/src/utils/config_utils.py
imports: import dataclasses
  import importlib
  from types import ModuleType
  from typing import Any, Dict, List, Type
  import yaml
  from llm_studio.python_configs.base import DefaultConfigProblemBase
  from llm_studio.src.utils.type_annotations import KNOWN_TYPE_ANNOTATIONS
label_desc: Use image node_id 5 for calling a global function with example usage: convert_cfg_base_to_nested_dictionary(cfg) and returns: grouped_cfg_dict