from typing import Optional
from typing import Dict
from typing import Any


def ensure_resampling_config_is_set(
    resampling_config: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
    """Set default downsampling_method and upsampling_method if these are missing.

    The default downsampling method is "mean".
    The default upsampling method is "pad".
    """

    if resampling_config is None:
        resampling_config = {}
    if resampling_config.get("downsampling_method", None) is None:
        resampling_config["downsampling_method"] = "mean"
    if resampling_config.get("upsampling_method", None) is None:
        resampling_config["upsampling_method"] = "pad"
    return resampling_config