class_docstr: Base class for configuration classes that need to respect the same API than PretrainedConfig but with a different
  configuration file name.
class_docstr_tok: ["Base","class","for","configuration","classes","that","need","to","respect","the","same","API","than","PretrainedConfig","but","with","a","different","configuration","file","name","."]
docstr: Save a configuration object to the directory `save_directory`, so that it can be re-loaded using the
  [`~PretrainedConfig.from_pretrained`] class method.
  
  Args:
      save_directory (`str` or `os.PathLike`):
          Directory where the configuration JSON file will be saved (will be created if it does not exist).
      push_to_hub (`bool`, *optional*, defaults to `False`):
          Whether or not to push your model to the Hugging Face model hub after saving it. You can specify the
          repository you want to push to with `repo_id` (will default to the name of `save_directory` in your
          namespace).
      kwargs:
          Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
docstr_tok: ["Save","a","configuration","object","to","the","directory","`","save_directory","`",",","so","that","it","can","be","re-loaded","using","the","[","`","~PretrainedConfig.from_pretrained","`","]","class","method",".","Args",":","save_directory","(","`","str","`","or","`","os.PathLike","`",")",":","Directory","where","the","configuration","JSON","file","will","be","saved","(","will","be","created","if","it","does","not","exist",")",".","push_to_hub","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","or","not","to","push","your","model","to","the","Hugging","Face","model","hub","after","saving","it",".","You","can","specify","the","repository","you","want","to","push","to","with","`","repo_id","`","(","will","default","to","the","name","of","`","save_directory","`","in","your","namespace",")",".","kwargs",":","Additional","key","word","arguments","passed","along","to","the","[","`","~utils.PushToHubMixin.push_to_hub","`","]","method","."]
code: def save_pretrained(
      self,
      save_directory: Union[str, os.PathLike],
      push_to_hub: bool = False,
      **kwargs,
  ):
      """
      Save a configuration object to the directory `save_directory`, so that it can be re-loaded using the
      [`~PretrainedConfig.from_pretrained`] class method.
  
      Args:
          save_directory (`str` or `os.PathLike`):
              Directory where the configuration JSON file will be saved (will be created if it does not exist).
          push_to_hub (`bool`, *optional*, defaults to `False`):
              Whether or not to push your model to the Hugging Face model hub after saving it. You can specify the
              repository you want to push to with `repo_id` (will default to the name of `save_directory` in your
              namespace).
          kwargs:
              Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
      """
      if os.path.isfile(save_directory):
          raise AssertionError(
              f"Provided path ({save_directory}) should be a directory, not a file"
          )
  
      # TODO: remove conditon once transformers release version is way above 4.22.
      if not _transformers_version_is_below_threshold:
          os.makedirs(save_directory, exist_ok=True)
  
      if push_to_hub:
          commit_message = kwargs.pop("commit_message", None)
          # TODO: remove once transformers release version is way above 4.22.
          if _transformers_version_is_below_threshold:
              repo = self._create_or_get_repo(save_directory, **kwargs)
          else:
              repo_id = kwargs.pop(
                  "repo_id", save_directory.split(os.path.sep)[-1]
              )
              repo_id = self._create_repo(repo_id, **kwargs)
  
              use_auth_token = kwargs.get("use_auth_token", None)
              token = (
                  HfFolder.get_token()
                  if use_auth_token is True
                  else use_auth_token
              )
  
              files_timestamps = self._get_files_timestamps(
                  save_directory
              )
  
      # TODO: remove once transformers release version is way above 4.22.
      if _transformers_version_is_below_threshold:
          os.makedirs(save_directory, exist_ok=True)
  
      # If we have a custom config, we copy the file defining it in the folder and set the attributes so it can be
      # loaded from the Hub.
      if self._auto_class is not None:
          custom_object_save(self, save_directory, config=self)
  
      # If we save using the predefined names, we can load using `from_pretrained`
      output_config_file = os.path.join(
          save_directory, self.CONFIG_NAME
      )
  
      self.to_json_file(output_config_file, use_diff=True)
      logger.info(f"Configuration saved in {output_config_file}")
  
      if push_to_hub:
          # TODO: remove once transformers release version is way above 4.22.
          if _transformers_version_is_below_threshold:
              url = self._push_to_hub(
                  repo, commit_message=commit_message
              )
              logger.info(
                  f"Configuration pushed to the hub in this commit: {url}"
              )
          else:
              self._upload_modified_files(
                  save_directory,
                  repo_id,
                  files_timestamps,
                  commit_message=commit_message,
                  token=token,
              )
  
file_path: optimum/optimum/configuration_utils.py
imports: import copy
  import json
  import os
  import re
  from typing import Any, Dict, List, Tuple, Union
  from huggingface_hub import HfFolder
  from packaging import version
  from transformers import PretrainedConfig
  from transformers import __version__
  from .utils import logging
  from .version import __version__
label_desc: Use image node_id 2 for calling the BaseConfig obj's underlying member method code with example usage: obj.save_pretrained(save_directory, push_to_hub) without return types