code: def export(
      task: TaskType,
      transform: dict[str, Any],
      input_size: tuple[int, int],
      model: AnomalyModule,
      export_mode: ExportMode,
      export_root: str | Path,
  ) -> None:
      """Export the model to onnx format and (optionally) convert to OpenVINO IR if export mode is set to OpenVINO.
  
      Args:
          task (TaskType): Task type.
          transform (dict[str, Any]): Data transforms (augmentatiions) used for the model.
          input_size (tuple[int, int]): Input size of the model.
          model (AnomalyModule): Anomaly model to export.
          export_mode (ExportMode): Mode to export the model. Torch, ONNX or OpenVINO.
          export_root (str | Path): Path to exported Torch, ONNX or OpenVINO IR.
      """
      # Create export directory.
      export_path = Path(export_root) / "weights" / export_mode.value
      export_path.mkdir(parents=True, exist_ok=True)
  
      # Get metadata.
      metadata = get_metadata(task, transform, model)
  
      if export_mode == ExportMode.TORCH:
          export_to_torch(model, metadata, export_path)
  
      elif export_mode in (ExportMode.ONNX, ExportMode.OPENVINO):
          # Write metadata to json file. The file is written in the same directory as the target model.
          with (Path(export_path) / "metadata.json").open(
              "w", encoding="utf-8"
          ) as metadata_file:
              json.dump(
                  metadata, metadata_file, ensure_ascii=False, indent=4
              )
  
          # Export model to onnx and convert to OpenVINO IR if export mode is set to OpenVINO.
          onnx_path = export_to_onnx(model, input_size, export_path)
          if export_mode == ExportMode.OPENVINO:
              export_to_openvino(
                  export_path, onnx_path, metadata, input_size
              )
  
      else:
          raise ValueError(f"Unknown export mode {export_mode}")
  
imports: from __future__ import annotations
  import json
  import logging
  import subprocess
  from enum import Enum
  from importlib.util import find_spec
  from pathlib import Path
  from typing import Any
  from warnings import warn
  import numpy
  import torch
  from torch import Tensor
  from torch.types import Number
  from anomalib.data.task_type import TaskType
  from anomalib.models.components import AnomalyModule
label_desc: Use image node_id 3 for calling a global function with example usage: export(task, transform, input_size, model, export_mode, export_root) without return types