def convert_center_crop_transform(transform: Transform) -> Transform:
    """Convert torchvision's CenterCrop to ExportableCenterCrop.

    This function recursively converts any ``CenterCrop`` transforms found within the
    provided transform or transform composition to ``ExportableCenterCrop``. This is
    necessary because torchvision's ``CenterCrop`` is not supported during ONNX
    export.

    Args:
        transform (Transform): Transform or composition of transforms to process.

    Returns:
        Transform: The processed transform with all ``CenterCrop`` transforms
            converted to ``ExportableCenterCrop``.

    Example:
        >>> from torchvision.transforms.v2 import Compose, CenterCrop
        >>> transform = Compose([
        ...     CenterCrop(224),
        ...     CenterCrop((256, 256))
        ... ])
        >>> transform = convert_center_crop_transform(transform)
        >>> # Now all CenterCrop transforms are converted to ExportableCenterCrop

    Note:
        This function creates new ``ExportableCenterCrop`` instances to replace the
        original ``CenterCrop`` transforms. The original transform object is
        returned with the replacements applied.
    """
    if isinstance(transform, CenterCrop):
        transform = ExportableCenterCrop(size=transform.size)
    if isinstance(transform, Compose):
        for index in range(len(transform.transforms)):
            tr = transform.transforms[index]
            transform.transforms[index] = convert_center_crop_transform(tr)
    return transform
Convert torchvision's CenterCrop to ExportableCenterCrop.

    This function recursively converts any ``CenterCrop`` transforms found within the
    provided transform or transform composition to ``ExportableCenterCrop``. This is
    necessary because torchvision's ``CenterCrop`` is not supported during ONNX
    export.

    Args:
        transform (Transform): Transform or composition of transforms to process.

    Returns:
        Transform: The processed transform with all ``CenterCrop`` transforms
            converted to ``ExportableCenterCrop``.

    Example:
        >>> from torchvision.transforms.v2 import Compose, CenterCrop
        >>> transform = Compose([
        ...     CenterCrop(224),
        ...     CenterCrop((256, 256))
        ... ])
        >>> transform = convert_center_crop_transform(transform)
        >>> # Now all CenterCrop transforms are converted to ExportableCenterCrop

    Note:
        This function creates new ``ExportableCenterCrop`` instances to replace the
        original ``CenterCrop`` transforms. The original transform object is
        returned with the replacements applied.
    
src/anomalib/pre_processing/utils/transform.py