def _deduce_dims(
    feature_extractor: TimmFeatureExtractor,
    input_size: tuple[int, int],
    layers: list[str],
) -> tuple[int, int]:
    """Run a dry run to deduce the dimensions of the extracted features.

    This function performs a forward pass to determine the dimensions of features
    extracted from the specified layers of the backbone network.

    Args:
        feature_extractor (TimmFeatureExtractor): Feature extraction model
        input_size (tuple[int, int]): Input image dimensions (height, width)
        layers (list[str]): Names of layers to extract features from

    Important:
        ``layers`` is assumed to be ordered and the first (``layers[0]``)
        is assumed to be the layer with largest resolution.

    Returns:
        tuple[int, int]: Dimensions of extracted features:
            - n_dims_original: Total number of feature dimensions
            - n_patches: Number of spatial patches
    """
    dimensions_mapping = dryrun_find_featuremap_dims(feature_extractor, input_size, layers)

    # the first layer in `layers` has the largest resolution
    first_layer_resolution = dimensions_mapping[layers[0]]["resolution"]
    n_patches = torch.tensor(first_layer_resolution).prod().int().item()

    # the original embedding size is the sum of the channels of all layers
    n_features_original = sum(dimensions_mapping[layer]["num_features"] for layer in layers)  # type: ignore[misc]

    return n_features_original, n_patches
Run a dry run to deduce the dimensions of the extracted features.

    This function performs a forward pass to determine the dimensions of features
    extracted from the specified layers of the backbone network.

    Args:
        feature_extractor (TimmFeatureExtractor): Feature extraction model
        input_size (tuple[int, int]): Input image dimensions (height, width)
        layers (list[str]): Names of layers to extract features from

    Important:
        ``layers`` is assumed to be ordered and the first (``layers[0]``)
        is assumed to be the layer with largest resolution.

    Returns:
        tuple[int, int]: Dimensions of extracted features:
            - n_dims_original: Total number of feature dimensions
            - n_patches: Number of spatial patches
    
src/anomalib/models/image/padim/torch_model.py