def export(
        self,
        model: AnomalibModule,
        export_type: ExportType | str,
        export_root: str | Path | None = None,
        model_file_name: str = "model",
        input_size: tuple[int, int] | None = None,
        compression_type: CompressionType | None = None,
        datamodule: AnomalibDataModule | None = None,
        metric: Metric | str | None = None,
        ov_args: dict[str, Any] | None = None,
        ckpt_path: str | Path | None = None,
    ) -> Path | None:
        r"""Export the model in PyTorch, ONNX or OpenVINO format.

        Args:
            model (AnomalibModule): Trained model.
            export_type (ExportType): Export type.
            export_root (str | Path | None, optional): Path to the output directory. If it is not set, the model is
                exported to trainer.default_root_dir. Defaults to None.
            model_file_name (str = "model"): Name of the exported model file. If it is not set, the model is
                is called "model". Defaults to "model".
            input_size (tuple[int, int] | None, optional): A statis input shape for the model, which is exported to ONNX
                and OpenVINO format. Defaults to None.
            compression_type (CompressionType | None, optional): Compression type for OpenVINO exporting only.
                Defaults to ``None``.
            datamodule (AnomalibDataModule | None, optional): Lightning datamodule.
                Must be provided if ``CompressionType.INT8_PTQ`` or `CompressionType.INT8_ACQ`` is selected
                (OpenVINO export only).
                Defaults to ``None``.
            metric (Metric | str | None, optional): Metric to measure quality loss when quantizing.
                Must be provided if ``CompressionType.INT8_ACQ`` is selected and must return higher value for better
                performance of the model (OpenVINO export only).
                Defaults to ``None``.
            ov_args (dict[str, Any] | None, optional): This is optional and used only for OpenVINO's model optimizer.
                Defaults to None.
            ckpt_path (str | Path | None): Checkpoint path. If provided, the model will be loaded from this path.

        Returns:
            Path: Path to the exported model.

        Raises:
            ValueError: If Dataset, Datamodule are not provided.

        CLI Usage:
            1. To export as a torch ``.pt`` file you can run the following command.
                ```python
                anomalib export --model Padim --export_type torch --ckpt_path <PATH_TO_CHECKPOINT>
                ```
            2. To export as an ONNX ``.onnx`` file you can run the following command.
                ```python
                anomalib export --model Padim --export_type onnx --ckpt_path <PATH_TO_CHECKPOINT> \
                --input_size "[256,256]"
                ```
            3. To export as an OpenVINO ``.xml`` and ``.bin`` file you can run the following command.
                ```python
                anomalib export --model Padim --export_type openvino --ckpt_path <PATH_TO_CHECKPOINT> \
                --input_size "[256,256] --compression_type FP16
                ```
            4. You can also quantize OpenVINO model with the following.
                ```python
                anomalib export --model Padim --export_type openvino --ckpt_path <PATH_TO_CHECKPOINT> \
                --input_size "[256,256]" --compression_type INT8_PTQ --data MVTec
                ```
        """
        export_type = ExportType(export_type)
        self._setup_trainer(model)
        if ckpt_path:
            ckpt_path = Path(ckpt_path).resolve()
            model = model.__class__.load_from_checkpoint(ckpt_path)

        if export_root is None:
            export_root = Path(self.trainer.default_root_dir)

        exported_model_path: Path | None = None
        if export_type == ExportType.TORCH:
            exported_model_path = model.to_torch(
                export_root=export_root,
                model_file_name=model_file_name,
            )
        elif export_type == ExportType.ONNX:
            exported_model_path = model.to_onnx(
                export_root=export_root,
                model_file_name=model_file_name,
                input_size=input_size,
            )
        elif export_type == ExportType.OPENVINO:
            exported_model_path = model.to_openvino(
                export_root=export_root,
                model_file_name=model_file_name,
                input_size=input_size,
                compression_type=compression_type,
                datamodule=datamodule,
                metric=metric,
                ov_args=ov_args,
            )
        else:
            logging.error(f"Export type {export_type} is not supported yet.")

        if exported_model_path:
            logging.info(f"Exported model to {exported_model_path}")
        return exported_model_path
Export the model in PyTorch, ONNX or OpenVINO format.

        Args:
            model (AnomalibModule): Trained model.
            export_type (ExportType): Export type.
            export_root (str | Path | None, optional): Path to the output directory. If it is not set, the model is
                exported to trainer.default_root_dir. Defaults to None.
            model_file_name (str = "model"): Name of the exported model file. If it is not set, the model is
                is called "model". Defaults to "model".
            input_size (tuple[int, int] | None, optional): A statis input shape for the model, which is exported to ONNX
                and OpenVINO format. Defaults to None.
            compression_type (CompressionType | None, optional): Compression type for OpenVINO exporting only.
                Defaults to ``None``.
            datamodule (AnomalibDataModule | None, optional): Lightning datamodule.
                Must be provided if ``CompressionType.INT8_PTQ`` or `CompressionType.INT8_ACQ`` is selected
                (OpenVINO export only).
                Defaults to ``None``.
            metric (Metric | str | None, optional): Metric to measure quality loss when quantizing.
                Must be provided if ``CompressionType.INT8_ACQ`` is selected and must return higher value for better
                performance of the model (OpenVINO export only).
                Defaults to ``None``.
            ov_args (dict[str, Any] | None, optional): This is optional and used only for OpenVINO's model optimizer.
                Defaults to None.
            ckpt_path (str | Path | None): Checkpoint path. If provided, the model will be loaded from this path.

        Returns:
            Path: Path to the exported model.

        Raises:
            ValueError: If Dataset, Datamodule are not provided.

        CLI Usage:
            1. To export as a torch ``.pt`` file you can run the following command.
                ```python
                anomalib export --model Padim --export_type torch --ckpt_path <PATH_TO_CHECKPOINT>
                ```
            2. To export as an ONNX ``.onnx`` file you can run the following command.
                ```python
                anomalib export --model Padim --export_type onnx --ckpt_path <PATH_TO_CHECKPOINT> \
                --input_size "[256,256]"
                ```
            3. To export as an OpenVINO ``.xml`` and ``.bin`` file you can run the following command.
                ```python
                anomalib export --model Padim --export_type openvino --ckpt_path <PATH_TO_CHECKPOINT> \
                --input_size "[256,256] --compression_type FP16
                ```
            4. You can also quantize OpenVINO model with the following.
                ```python
                anomalib export --model Padim --export_type openvino --ckpt_path <PATH_TO_CHECKPOINT> \
                --input_size "[256,256]" --compression_type INT8_PTQ --data MVTec
                ```
        
src/anomalib/engine/engine.py