docstr: Saves a model and its configuration file to a directory, so that it can be re-loaded using the
  [`from_pretrained`] class method.
  
  Args:
      save_directory (`Union[str, os.PathLike]`):
          Directory to which to save. Will be created if it doesn't 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.
  
          <Tip warning={true}>
  
          Using `push_to_hub=True` will synchronize the repository you are pushing to with `save_directory`,
          which requires `save_directory` to be a local clone of the repo you are pushing to if it's an existing
          folder. Pass along `temp_dir=True` to use a temporary directory instead.
  
          </Tip>
docstr_tok: ["Saves","a","model","and","its","configuration","file","to","a","directory",",","so","that","it","can","be","re-loaded","using","the","[","`","from_pretrained","`","]","class","method",".","Args",":","save_directory","(","`","Union","[","str",",","os.PathLike","]","`",")",":","Directory","to","which","to","save",".","Will","be","created","if","it","does","n't","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",".","<","Tip","warning=","{","true","}",">","Using","`","push_to_hub=True","`","will","synchronize","the","repository","you","are","pushing","to","with","`","save_directory","`",",","which","requires","`","save_directory","`","to","be","a","local","clone","of","the","repo","you","are","pushing","to","if","it","'s","an","existing","folder",".","Pass","along","`","temp_dir=True","`","to","use","a","temporary","directory","instead",".","<","\/Tip",">"]
code: def save_pretrained(
      self,
      save_directory: Union[str, os.PathLike],
      push_to_hub: bool = False,
      **kwargs,
  ):
      """
      Saves a model and its configuration file to a directory, so that it can be re-loaded using the
      [`from_pretrained`] class method.
  
      Args:
          save_directory (`Union[str, os.PathLike]`):
              Directory to which to save. Will be created if it doesn't 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.
  
              <Tip warning={true}>
  
              Using `push_to_hub=True` will synchronize the repository you are pushing to with `save_directory`,
              which requires `save_directory` to be a local clone of the repo you are pushing to if it's an existing
              folder. Pass along `temp_dir=True` to use a temporary directory instead.
  
              </Tip>
      """
      if os.path.isfile(save_directory):
          logger.error(
              f"Provided path ({save_directory}) should be a directory, not a file"
          )
          return
  
      os.makedirs(save_directory, exist_ok=True)
  
      self._save_config(save_directory)
      for preprocessor in self.preprocessors:
          preprocessor.save_pretrained(save_directory)
      self._save_pretrained(save_directory)
  
      if push_to_hub:
          return self.push_to_hub(save_directory, **kwargs)
  
imports: import logging
  import os
  import subprocess
  from abc import ABC, abstractmethod
  from pathlib import Path
  from typing import TYPE_CHECKING, Optional, Union
  from huggingface_hub import HfApi, HfFolder
  from transformers import AutoConfig, PretrainedConfig, add_start_docstrings
  from .exporters import TasksManager
  from .utils import CONFIG_NAME
label_desc: Use image node_id 4 for calling the OptimizedModel obj's underlying member method code with example usage: obj.save_pretrained(save_directory, push_to_hub) and returns: self