def flatten_dict(config: dict, prefix: str = "") -> dict:
    """Flatten a nested dictionary using dot notation.

    Takes a nested dictionary and flattens it into a single-level dictionary where
    nested keys are joined using dot notation. This is useful for converting
    hierarchical configurations into a flat format.

    Args:
        config: Nested dictionary to flatten. Can contain arbitrary levels of
            nesting.
        prefix: Optional string prefix to prepend to all flattened keys. Defaults
            to empty string.

    Returns:
        dict: Flattened dictionary where nested keys are joined with dots.
            For example, ``{"a": {"b": 1}}`` becomes ``{"a.b": 1}``.

    Examples:
        Basic nested dictionary flattening:

        >>> config = {
        ...     "dataset": {
        ...         "category": "bottle",
        ...         "image_size": 224
        ...     },
        ...     "model_name": "padim"
        ... }
        >>> flattened = flatten_dict(config)
        >>> print(flattened)  # doctest: +SKIP
        {
            'dataset.category': 'bottle',
            'dataset.image_size': 224,
            'model_name': 'padim'
        }

        With custom prefix:

        >>> flattened = flatten_dict(config, prefix="config.")
        >>> print(flattened)  # doctest: +SKIP
        {
            'config.dataset.category': 'bottle',
            'config.dataset.image_size': 224,
            'config.model_name': 'padim'
        }
    """
    out = {}
    for key, value in config.items():
        if isinstance(value, dict):
            out.update(flatten_dict(value, f"{prefix}{key}."))
        else:
            out[f"{prefix}{key}"] = value
    return out
Flatten a nested dictionary using dot notation.

    Takes a nested dictionary and flattens it into a single-level dictionary where
    nested keys are joined using dot notation. This is useful for converting
    hierarchical configurations into a flat format.

    Args:
        config: Nested dictionary to flatten. Can contain arbitrary levels of
            nesting.
        prefix: Optional string prefix to prepend to all flattened keys. Defaults
            to empty string.

    Returns:
        dict: Flattened dictionary where nested keys are joined with dots.
            For example, ``{"a": {"b": 1}}`` becomes ``{"a.b": 1}``.

    Examples:
        Basic nested dictionary flattening:

        >>> config = {
        ...     "dataset": {
        ...         "category": "bottle",
        ...         "image_size": 224
        ...     },
        ...     "model_name": "padim"
        ... }
        >>> flattened = flatten_dict(config)
        >>> print(flattened)  # doctest: +SKIP
        {
            'dataset.category': 'bottle',
            'dataset.image_size': 224,
            'model_name': 'padim'
        }

        With custom prefix:

        >>> flattened = flatten_dict(config, prefix="config.")
        >>> print(flattened)  # doctest: +SKIP
        {
            'config.dataset.category': 'bottle',
            'config.dataset.image_size': 224,
            'config.model_name': 'padim'
        }
    
src/anomalib/utils/config.py