class_docstr: This is a generic configuration class that will be instantiated as one of the configuration classes of the library
  when created with the [`~AutoConfig.from_pretrained`] class method.
  
  This class cannot be instantiated directly using `__init__()` (throws an error).
docstr: Instantiate one of the configuration classes of the library from a pretrained model configuration.
  
  The configuration class to instantiate is selected based on the `model_type` property of the config object that
  is loaded, or when it's missing, by falling back to using pattern matching on `pretrained_model_name_or_path`:
  
  List options
  
  Args:
      pretrained_model_name_or_path (`str` or `os.PathLike`):
          Can be either:
  
              - A string, the *model id* of a pretrained model configuration hosted inside a model repo on
                huggingface.co. Valid model ids can be located at the root-level, like `bert-base-uncased`, or
                namespaced under a user or organization name, like `dbmdz/bert-base-german-cased`.
              - A path to a *directory* containing a configuration file saved using the
                [`~PretrainedConfig.save_pretrained`] method, or the [`~PreTrainedModel.save_pretrained`] method,
                e.g., `./my_model_directory/`.
              - A path or url to a saved configuration JSON *file*, e.g.,
                `./my_model_directory/configuration.json`.
      cache_dir (`str` or `os.PathLike`, *optional*):
          Path to a directory in which a downloaded pretrained model configuration should be cached if the
          standard cache should not be used.
      force_download (`bool`, *optional*, defaults to `False`):
          Whether or not to force the (re-)download the model weights and configuration files and override the
          cached versions if they exist.
      resume_download (`bool`, *optional*, defaults to `False`):
          Whether or not to delete incompletely received files. Will attempt to resume the download if such a
          file exists.
      proxies (`Dict[str, str]`, *optional*):
          A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
          'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
      revision (`str`, *optional*, defaults to `"main"`):
          The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
          git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
          identifier allowed by git.
      return_unused_kwargs (`bool`, *optional*, defaults to `False`):
          If `False`, then this function returns just the final configuration object.
  
          If `True`, then this functions returns a `Tuple(config, unused_kwargs)` where *unused_kwargs* is a
          dictionary consisting of the key/value pairs whose keys are not configuration attributes: i.e., the
          part of `kwargs` which has not been used to update `config` and is otherwise ignored.
      trust_remote_code (`bool`, *optional*, defaults to `False`):
          Whether or not to allow for custom models defined on the Hub in their own modeling files. This option
          should only be set to `True` for repositories you trust and in which you have read the code, as it will
          execute code present on the Hub on your local machine.
      kwargs(additional keyword arguments, *optional*):
          The values in kwargs of any keys which are configuration attributes will be used to override the loaded
          values. Behavior concerning key/value pairs whose keys are *not* configuration attributes is controlled
          by the `return_unused_kwargs` keyword parameter.
  
  Examples:
  
  ```python
  >>> from transformers import AutoConfig
  
  >>> # Download configuration from huggingface.co and cache.
  >>> config = AutoConfig.from_pretrained("bert-base-uncased")
  
  >>> # Download configuration from huggingface.co (user-uploaded) and cache.
  >>> config = AutoConfig.from_pretrained("dbmdz/bert-base-german-cased")
  
  >>> # If configuration file is in a directory (e.g., was saved using *save_pretrained('./test/saved_model/')*).
  >>> config = AutoConfig.from_pretrained("./test/bert_saved_model/")
  
  >>> # Load a specific configuration file.
  >>> config = AutoConfig.from_pretrained("./test/bert_saved_model/my_configuration.json")
  
  >>> # Change some config attributes when loading a pretrained config.
  >>> config = AutoConfig.from_pretrained("bert-base-uncased", output_attentions=True, foo=False)
  >>> config.output_attentions
  True
  
  >>> config, unused_kwargs = AutoConfig.from_pretrained(
  ...     "bert-base-uncased", output_attentions=True, foo=False, return_unused_kwargs=True
  ... )
  >>> config.output_attentions
  True
  
  >>> unused_kwargs
  {'foo': False}
  ```
code: def from_pretrained(cls, pretrained_model_name_or_path, **kwargs):
      r"""
      Instantiate one of the configuration classes of the library from a pretrained model configuration.
  
      The configuration class to instantiate is selected based on the `model_type` property of the config object that
      is loaded, or when it's missing, by falling back to using pattern matching on `pretrained_model_name_or_path`:
  
      List options
  
      Args:
          pretrained_model_name_or_path (`str` or `os.PathLike`):
              Can be either:
  
                  - A string, the *model id* of a pretrained model configuration hosted inside a model repo on
                    huggingface.co. Valid model ids can be located at the root-level, like `bert-base-uncased`, or
                    namespaced under a user or organization name, like `dbmdz/bert-base-german-cased`.
                  - A path to a *directory* containing a configuration file saved using the
                    [`~PretrainedConfig.save_pretrained`] method, or the [`~PreTrainedModel.save_pretrained`] method,
                    e.g., `./my_model_directory/`.
                  - A path or url to a saved configuration JSON *file*, e.g.,
                    `./my_model_directory/configuration.json`.
          cache_dir (`str` or `os.PathLike`, *optional*):
              Path to a directory in which a downloaded pretrained model configuration should be cached if the
              standard cache should not be used.
          force_download (`bool`, *optional*, defaults to `False`):
              Whether or not to force the (re-)download the model weights and configuration files and override the
              cached versions if they exist.
          resume_download (`bool`, *optional*, defaults to `False`):
              Whether or not to delete incompletely received files. Will attempt to resume the download if such a
              file exists.
          proxies (`Dict[str, str]`, *optional*):
              A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
              'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
          revision (`str`, *optional*, defaults to `"main"`):
              The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
              git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
              identifier allowed by git.
          return_unused_kwargs (`bool`, *optional*, defaults to `False`):
              If `False`, then this function returns just the final configuration object.
  
              If `True`, then this functions returns a `Tuple(config, unused_kwargs)` where *unused_kwargs* is a
              dictionary consisting of the key/value pairs whose keys are not configuration attributes: i.e., the
              part of `kwargs` which has not been used to update `config` and is otherwise ignored.
          trust_remote_code (`bool`, *optional*, defaults to `False`):
              Whether or not to allow for custom models defined on the Hub in their own modeling files. This option
              should only be set to `True` for repositories you trust and in which you have read the code, as it will
              execute code present on the Hub on your local machine.
          kwargs(additional keyword arguments, *optional*):
              The values in kwargs of any keys which are configuration attributes will be used to override the loaded
              values. Behavior concerning key/value pairs whose keys are *not* configuration attributes is controlled
              by the `return_unused_kwargs` keyword parameter.
  
      Examples:
  
      ```python
      >>> from transformers import AutoConfig
  
      >>> # Download configuration from huggingface.co and cache.
      >>> config = AutoConfig.from_pretrained("bert-base-uncased")
  
      >>> # Download configuration from huggingface.co (user-uploaded) and cache.
      >>> config = AutoConfig.from_pretrained("dbmdz/bert-base-german-cased")
  
      >>> # If configuration file is in a directory (e.g., was saved using *save_pretrained('./test/saved_model/')*).
      >>> config = AutoConfig.from_pretrained("./test/bert_saved_model/")
  
      >>> # Load a specific configuration file.
      >>> config = AutoConfig.from_pretrained("./test/bert_saved_model/my_configuration.json")
  
      >>> # Change some config attributes when loading a pretrained config.
      >>> config = AutoConfig.from_pretrained("bert-base-uncased", output_attentions=True, foo=False)
      >>> config.output_attentions
      True
  
      >>> config, unused_kwargs = AutoConfig.from_pretrained(
      ...     "bert-base-uncased", output_attentions=True, foo=False, return_unused_kwargs=True
      ... )
      >>> config.output_attentions
      True
  
      >>> unused_kwargs
      {'foo': False}
      ```"""
      kwargs["_from_auto"] = True
      kwargs["name_or_path"] = pretrained_model_name_or_path
      trust_remote_code = kwargs.pop("trust_remote_code", False)
      config_dict, unused_kwargs = PretrainedConfig.get_config_dict(
          pretrained_model_name_or_path, **kwargs
      )
      if (
          "auto_map" in config_dict
          and "AutoConfig" in config_dict["auto_map"]
      ):
          if not trust_remote_code:
              raise ValueError(
                  f"Loading {pretrained_model_name_or_path} requires you to execute the configuration file in that"
                  " repo on your local machine. Make sure you have read the code there to avoid malicious use, then"
                  " set the option `trust_remote_code=True` to remove this error."
              )
          if kwargs.get("revision", None) is None:
              logger.warning(
                  "Explicitly passing a `revision` is encouraged when loading a configuration with custom code to "
                  "ensure no malicious code has been contributed in a newer revision."
              )
          class_ref = config_dict["auto_map"]["AutoConfig"]
          module_file, class_name = class_ref.split(".")
          config_class = get_class_from_dynamic_module(
              pretrained_model_name_or_path,
              module_file + ".py",
              class_name,
              **kwargs,
          )
          return config_class.from_pretrained(
              pretrained_model_name_or_path, **kwargs
          )
      elif "model_type" in config_dict:
          config_class = CONFIG_MAPPING[config_dict["model_type"]]
          return config_class.from_dict(config_dict, **unused_kwargs)
      else:
          # Fallback: use pattern matching on the string.
          # We go from longer names to shorter names to catch roberta before bert (for instance)
          for pattern in sorted(
              CONFIG_MAPPING.keys(), key=len, reverse=True
          ):
              if pattern in str(pretrained_model_name_or_path):
                  return CONFIG_MAPPING[pattern].from_dict(
                      config_dict, **unused_kwargs
                  )
  
      raise ValueError(
          f"Unrecognized model in {pretrained_model_name_or_path}. "
          f"Should have a `model_type` key in its {CONFIG_NAME}, or contain one of the following strings "
          f"in its name: {', '.join(CONFIG_MAPPING.keys())}"
      )
  
imports: import importlib
  import re
  import warnings
  from collections import OrderedDict
  from typing import List, Union
  from ...configuration_utils import PretrainedConfig
  from ...dynamic_module_utils import get_class_from_dynamic_module
  from ...utils import CONFIG_NAME, logging
label_desc: Use image node_id 3 for calling the AutoConfig obj's underlying member method code with example usage: obj.from_pretrained(cls, pretrained_model_name_or_path) and returns: config_class, config_class, CONFIG_MAPPING