code: def flatten_sweep_params(params_dict: DictConfig) -> DictConfig:
      """Flatten the nested parameters section of the config object.
  
      We need to flatten the params so that all the nested keys are concatenated into a single string.
      This is useful when
      - We need to do a cartesian product of all the combinations of the configuration for grid search.
      - Save keys as headers for csv
      - Add the config to `wandb` sweep.
  
      Args:
          params_dict: DictConfig: The dictionary containing the hpo parameters in the original, nested, structure.
  
      Returns:
          flattened version of the parameter dictionary.
      """
  
      def flatten_nested_dict(
          nested_params: DictConfig,
          keys: list[str],
          flattened_params: DictConfig,
      ) -> None:
          """Flatten nested dictionary.
  
          Recursive helper function that traverses the nested config object and stores the leaf nodes in a flattened
          dictionary.
  
          Args:
              nested_params: DictConfig: config object containing the original parameters.
              keys: list[str]: list of keys leading to the current location in the config.
              flattened_params: DictConfig: Dictionary in which the flattened parameters are stored.
          """
          for name, cfg in nested_params.items():
              if isinstance(cfg, DictConfig):
                  flatten_nested_dict(
                      cfg, keys + [str(name)], flattened_params
                  )
              else:
                  key = ".".join(keys + [str(name)])
                  flattened_params[key] = cfg
  
      flattened_params_dict = DictConfig({})
      flatten_nested_dict(params_dict, [], flattened_params_dict)
  
      return flattened_params_dict
  
file_path: anomalib/src/anomalib/utils/sweep/config.py
imports: from __future__ import annotations
  import itertools
  import operator
  from collections.abc import Iterable, ValuesView
  from functools import reduce
  from typing import Any, Generator
  from omegaconf import DictConfig
label_desc: Use image node_id 2 for calling a global function with example usage: flatten_sweep_params(params_dict) and returns: flattened_params_dict