def get_ensemble_model(
    model_args: dict,
    input_size: int | tuple[int, int],
    normalization_stage: NormalizationStage,
) -> AnomalibModule:
    """Get model prepared for ensemble training.

    Args:
        model_args (dict): tiled ensemble model configuration.
        input_size (int | tuple[int, int]): individual model input size.
        normalization_stage (NormalizationStage): stage when normalization performed.

    Returns:
        AnomalyModule: model with input_size setup
    """
    # first make temporary model to get object
    temp_model = get_model(model_args)
    if isinstance(input_size, int):
        input_size = (input_size, input_size)
    # create custom pre_proc with correct input size
    # since we can't modify input_size directly (needed during instantiation by some models like FastFlow)
    pre_processor = temp_model.configure_pre_processor(input_size)
    # make actual model with correct input size
    model: AnomalibModule = get_model(model_args, pre_processor=pre_processor, visualizer=False)
    if model.pre_processor is not None:
        model_pre_processor: PreProcessor = model.pre_processor

        # drop Resize in all cases since it gets copied to datamodule, and we don't want that!
        pre_transforms = model_pre_processor.transform
        if isinstance(pre_transforms, Resize):
            update_transform = []
        elif isinstance(pre_transforms, Compose):
            update_transform = Compose([
                transform for transform in pre_transforms.transforms if not isinstance(transform, Resize)
            ])
        elif pre_transforms is not None:
            update_transform = pre_transforms
        else:
            update_transform = []

        model_pre_processor.transform = update_transform
        model_pre_processor.export_transform = get_exportable_transform(update_transform)

    if model.post_processor is not None:
        model_post_processor: PostProcessor = model.post_processor
        # set model normalisation only if the stage is set to tile level (but thresholding is always applied)
        model_post_processor.enable_normalization = normalization_stage == NormalizationStage.TILE

    return model
Get model prepared for ensemble training.

    Args:
        model_args (dict): tiled ensemble model configuration.
        input_size (int | tuple[int, int]): individual model input size.
        normalization_stage (NormalizationStage): stage when normalization performed.

    Returns:
        AnomalyModule: model with input_size setup
    
src/anomalib/pipelines/tiled_ensemble/components/utils/helper_functions.py