class_docstr: Handles the ONNX Runtime optimization process for models shared on huggingface.co/models.
class_docstr_tok: ["Handles","the","ONNX","Runtime","optimization","process","for","models","shared","on","huggingface.co\/models","."]
docstr: Args:
      onnx_model_path (`List[os.PathLike]`):
          The paths of the onnx models to optimize.
      config ([`~transformers.PretrainedConfig`]):
          An instance of the configuration associated to the model to optimize.
      from_ortmodel (`bool`, defaults to `False`):
          Whether the model being optimized is already loaded into an ORTModel, or if it was passed from disk.
docstr_tok: ["Args",":","onnx_model_path","(","`","List","[","os.PathLike","]","`",")",":","The","paths","of","the","onnx","models","to","optimize",".","config","(","[","`","~transformers.PretrainedConfig","`","]",")",":","An","instance","of","the","configuration","associated","to","the","model","to","optimize",".","from_ortmodel","(","`","bool","`",",","defaults","to","`","False","`",")",":","Whether","the","model","being","optimized","is","already","loaded","into","an","ORTModel",",","or","if","it","was","passed","from","disk","."]
code: def __init__(
      self,
      onnx_model_path: List[os.PathLike],
      config: "PretrainedConfig",
      from_ortmodel: bool = False,
  ):
      """
      Args:
          onnx_model_path (`List[os.PathLike]`):
              The paths of the onnx models to optimize.
          config ([`~transformers.PretrainedConfig`]):
              An instance of the configuration associated to the model to optimize.
          from_ortmodel (`bool`, defaults to `False`):
              Whether the model being optimized is already loaded into an ORTModel, or if it was passed from disk.
      """
      super().__init__()
      self.onnx_model_path = onnx_model_path
      self.config = config
      self.model_type = self.config.model_type
      self.from_ortmodel = from_ortmodel
  
      try:
          self.normalized_config = (
              NormalizedConfigManager.get_normalized_config_class(
                  self.model_type
              )(self.config)
          )
      except KeyError:
          raise NotImplementedError(
              f"Tried to use ORTOptimizer for the model type {self.model_type}, but it is not available yet. Please open an issue"
              " or submit a PR at https://github.com/huggingface/optimum."
          )
  
imports: import gc
  import os
  from pathlib import Path
  from typing import TYPE_CHECKING, Dict, List, Optional, Union
  import onnx
  from onnx import load_model
  from transformers.models.auto.configuration_auto import AutoConfig
  from onnxruntime.transformers.onnx_model_bert import BertOnnxModel
  from onnxruntime.transformers.optimizer import optimize_model
  from ..onnx.utils import check_model_uses_external_data
  from ..utils import CONFIG_NAME, NormalizedConfigManager, logging
  from ..utils.save_utils import maybe_save_preprocessors
  from .configuration import OptimizationConfig, ORTConfig
  from .modeling_decoder import ORTModelForCausalLM
  from .modeling_ort import ORTModel
  from .modeling_seq2seq import ORTModelForConditionalGeneration
  from .utils import ONNX_WEIGHTS_NAME, ORTConfigManager
label_desc: Use image node_id 1 to create a new ORTOptimizer object  with example: obj = ORTOptimizer(onnx_model_path, config, from_ortmodel)