code: def _get_model_class(config, model_mapping):
      supported_models = model_mapping[type(config)]
      if not isinstance(supported_models, (list, tuple)):
          return supported_models
  
      name_to_model = {
          model.__name__: model for model in supported_models
      }
      architectures = getattr(config, "architectures", [])
      for arch in architectures:
          if arch in name_to_model:
              return name_to_model[arch]
          elif f"TF{arch}" in name_to_model:
              return name_to_model[f"TF{arch}"]
          elif f"Flax{arch}" in name_to_model:
              return name_to_model[f"Flax{arch}"]
  
      # If not architecture is set in the config or match the supported models, the first element of the tuple is the
      # defaults.
      return supported_models[0]
  
imports: import importlib
  from collections import OrderedDict
  from ...configuration_utils import PretrainedConfig
  from ...dynamic_module_utils import get_class_from_dynamic_module
  from ...utils import copy_func, logging
  from .configuration_auto import AutoConfig, model_type_to_module_name, replace_list_option_in_docstrings
label_desc: Use image node_id 1 for calling a global function with example usage: _get_model_class(config, model_mapping) and returns: supported_models, supported_models, name_to_model, name_to_model, name_to_model