docstr: Exports the PyTorch models to ONNX ahead of time to avoid multiple exports during the tests.
  We don't use unittest setUpClass, in order to still be able to run individual tests.
docstr_tok: ["Exports","the","PyTorch","models","to","ONNX","ahead","of","time","to","avoid","multiple","exports","during","the","tests",".","We","do","n't","use","unittest","setUpClass",",","in","order","to","still","be","able","to","run","individual","tests","."]
code: def _setup(self, model_args: Dict):
      """
      Exports the PyTorch models to ONNX ahead of time to avoid multiple exports during the tests.
      We don't use unittest setUpClass, in order to still be able to run individual tests.
      """
      model_arch = model_args["model_arch"]
      model_arch_and_params = model_args["test_name"]
  
      # TODO: this should actually be checked in ORTModel!
      task = self.TASK
      if "use_cache" in model_args and model_args["use_cache"] is True:
          task = task + "-with-past"
  
      if (
          "use_cache" in model_args
          and task
          not in TasksManager.get_supported_tasks_for_model_type(
              model_arch.replace("_", "-"), exporter="onnx"
          )
      ):
          self.skipTest("Unsupported export case")
  
      model_ids = MODEL_NAMES[model_arch]
      if isinstance(model_ids, dict):
          model_ids = list(model_ids.keys())
      else:
          model_ids = [model_ids]
  
      if model_arch_and_params not in self.onnx_model_dirs:
          self.onnx_model_dirs[model_arch_and_params] = {}
  
          # model_args will contain kwargs to pass to ORTModel.from_pretrained()
          model_args.pop("test_name")
          model_args.pop("model_arch")
  
          for idx, model_id in enumerate(model_ids):
              if (
                  model_arch == "encoder-decoder"
                  and task not in MODEL_NAMES[model_arch][model_id]
              ):
                  # The model with use_cache=True is not supported for bert as a decoder")
                  continue
  
              set_seed(SEED)
              onnx_model = self.ORTMODEL_CLASS.from_pretrained(
                  model_id,
                  **model_args,
                  use_io_binding=False,
                  export=True,
              )
  
              model_dir = tempfile.mkdtemp(
                  prefix=f"{model_arch_and_params}_{self.TASK}_{model_id.replace('/', '_')}"
              )
              onnx_model.save_pretrained(model_dir)
              if isinstance(MODEL_NAMES[model_arch], dict):
                  self.onnx_model_dirs[model_arch_and_params][
                      model_id
                  ] = model_dir
              else:
                  self.onnx_model_dirs[
                      model_arch_and_params
                  ] = model_dir
  
file_path: optimum/tests/onnxruntime/utils_onnxruntime_tests.py
imports: import shutil
  import tempfile
  import unittest
  from typing import Dict
  import numpy
  import torch
  from transformers import set_seed
  from optimum.exporters import TasksManager
label_desc: Use image node_id 2 for calling the ORTModelTestMixin obj's underlying member method code with example usage: obj._setup(model_args) without return types