code: def _get_models_to_test(
      export_models_dict: Dict, library_name: str = "transformers"
  ):
      models_to_test = []
      if is_torch_available():
          for (
              model_type,
              model_names_tasks,
          ) in export_models_dict.items():
              task_config_mapping = (
                  TasksManager.get_supported_tasks_for_model_type(
                      model_type, "onnx", library_name=library_name
                  )
              )
  
              if isinstance(
                  model_names_tasks, str
              ):  # test export of all tasks on the same model
                  tasks = list(task_config_mapping.keys())
                  model_tasks = {model_names_tasks: tasks}
              else:
                  unique_tasks = set()
                  for tasks in model_names_tasks.values():
                      for task in tasks:
                          unique_tasks.add(task)
                  n_tested_tasks = len(unique_tasks)
                  if n_tested_tasks != len(task_config_mapping):
                      raise ValueError(
                          f"Not all tasks are tested for {model_type}."
                      )
                  model_tasks = model_names_tasks  # possibly, test different tasks on different models
  
              for model_name, tasks in model_tasks.items():
                  for task in tasks:
                      if (
                          model_type == "encoder-decoder"
                          and task == "text2text-generation-with-past"
                      ):
                          # The model uses bert as decoder and does not support past key values
                          continue
                      onnx_config_class = (
                          TasksManager.get_exporter_config_constructor(
                              "onnx",
                              task=task,
                              model_type=model_type,
                              library_name=library_name,
                          )
                      )
  
                      # Refer to https://github.com/huggingface/optimum/blob/0b08a1fd19005b7334aa923433b3544bd2b11ff2/optimum/exporters/tasks.py#L65
                      if hasattr(onnx_config_class.func, "__self__"):
                          variants = (
                              onnx_config_class.func.__self__.VARIANTS
                          )
                      else:
                          variants = onnx_config_class.func.VARIANTS
  
                      for variant in variants.keys():
                          models_to_test.append(
                              (
                                  f"{model_type}_{task}_{variant}_{model_name}",
                                  model_type,
                                  model_name,
                                  task,
                                  variant,
                                  False,
                                  False,
                              )
                          )
  
                          # -with-past and monolith cases are absurd, so we don't test them as not supported
                          if any(
                              task == ort_special_task
                              for ort_special_task in [
                                  "text-generation",
                                  "text2text-generation",
                                  "automatic-speech-recognition",
                                  "image-to-text",
                              ]
                          ):
                              models_to_test.append(
                                  (
                                      f"{model_type}_{task}_monolith_{variant}_{model_name}",
                                      model_type,
                                      model_name,
                                      task,
                                      variant,
                                      True,
                                      False,
                                  )
                              )
  
                          # For other tasks, we don't test --no-post-process as there is none anyway
                          if task in [
                              "feature-extraction-with-past",
                              "text-generation-with-past",
                              "automatic-speech-recognition-with-past",
                              "image-to-text-with-past",
                              "text2text-generation-with-past",
                          ]:
                              models_to_test.append(
                                  (
                                      f"{model_type}_{task}_no_postprocess_{variant}_{model_name}",
                                      model_type,
                                      model_name,
                                      task,
                                      variant,
                                      False,
                                      True,
                                  )
                              )
  
                  # TODO: segformer task can not be automatically inferred
                  # TODO: xlm-roberta model auto-infers text-generation, but we don't support it
                  # TODO: perceiver auto-infers default, but we don't support it (why?)
                  # TODO: encoder-decoder auto-infers text3text-generation, but it uses bert as decoder and does not support past key values
                  # TODO: vision-encoder-decoder tiny models have wrong labels on the Hub
                  # TODO: unispeech-sat tiny models have wrong labels on the Hub
                  if model_type not in [
                      "segformer",
                      "xlm-roberta",
                      "perceiver",
                      "encoder-decoder",
                      "vision-encoder-decoder",
                      "unispeech-sat",
                  ]:
                      models_to_test.append(
                          (
                              f"{model_type}_no_task_{model_name}",
                              model_type,
                              model_name,
                              "auto",
                              "default",
                              False,
                              False,
                          )
                      )
  
          return sorted(models_to_test)
      else:
          # Returning some dummy test that should not be ever called because of the @require_torch / @require_tf
          # decorators.
          # The reason for not returning an empty list is because parameterized.expand complains when it's empty.
          return [("dummy", "dummy", "dummy")]
  
imports: import os
  import subprocess
  import unittest
  from pathlib import Path
  from tempfile import TemporaryDirectory
  from typing import Dict, Optional
  import onnx
  import pytest
  from parameterized import parameterized
  from transformers import AutoModelForSequenceClassification, AutoTokenizer, is_torch_available
  from transformers.testing_utils import require_torch, require_torch_gpu, require_vision, slow
  from optimum.exporters.error_utils import MinimumVersionError
  from optimum.exporters.onnx.__main__ import main_export
  from optimum.onnxruntime import ONNX_DECODER_MERGED_NAME, ONNX_DECODER_NAME, ONNX_DECODER_WITH_PAST_NAME, ONNX_ENCODER_NAME
  from optimum.utils.testing_utils import require_diffusers, require_sentence_transformers, require_timm
  from ..exporters_utils import PYTORCH_EXPORT_MODELS_TINY, PYTORCH_SENTENCE_TRANSFORMERS_MODEL, PYTORCH_STABLE_DIFFUSION_MODEL, PYTORCH_TIMM_MODEL
label_desc: Use image node_id 1 for calling a global function with example usage: _get_models_to_test(export_models_dict, library_name) and returns: sorted, list