code: def test_export_model_callback(dummy_datamodule: MVTec, export_mode):
      """Tests if an optimized model is created."""
  
      config = get_test_configurable_parameters(
          config_path="tests/pre_merge/utils/callbacks/export_callback/dummy_config.yml"
      )
  
      with tempfile.TemporaryDirectory() as tmp_dir:
          config.project.path = tmp_dir
          model = DummyLightningModule(hparams=config)
          model.callbacks = [
              ExportCallback(
                  input_size=config.model.input_size,
                  dirpath=os.path.join(tmp_dir),
                  filename="model",
                  export_mode=export_mode,
              ),
              EarlyStopping(monitor=config.model.metric),
          ]
          trainer = pl.Trainer(
              gpus=1,
              callbacks=model.callbacks,
              logger=False,
              enable_checkpointing=False,
              max_epochs=1,
          )
          trainer.fit(model, datamodule=dummy_datamodule)
  
          if export_mode == ExportMode.OPENVINO:
              assert os.path.exists(
                  os.path.join(tmp_dir, "weights/openvino/model.bin")
              ), "Failed to generate OpenVINO model"
          elif export_mode == ExportMode.ONNX:
              assert os.path.exists(
                  os.path.join(tmp_dir, "weights/onnx/model.onnx")
              ), "Failed to generate ONNX model"
          else:
              raise ValueError(
                  f"Unknown export_mode {export_mode}. Supported modes: onnx or openvino."
              )
  
file_path: anomalib/tests/pre_merge/utils/callbacks/export_callback/test_export.py
imports: import os
  import tempfile
  import pytest
  import pytorch_lightning
  from pytorch_lightning.callbacks.early_stopping import EarlyStopping
  from anomalib.data.mvtec import MVTec
  from anomalib.data.utils import random_split
  from anomalib.deploy import ExportMode
  from anomalib.utils.callbacks.export import ExportCallback
  from tests.helpers.config import get_test_configurable_parameters
  from tests.helpers.dataset import get_dataset_path
  from tests.pre_merge.utils.callbacks.export_callback.dummy_lightning_model import DummyLightningModule
label_desc: Use image node_id 2 for calling a global function with example usage: test_export_model_callback(dummy_datamodule, export_mode) without return types