class_docstr: This is a feature extraction mixin used to provide saving/loading functionality for sequential and image feature
  extractors.
class_docstr_tok: ["This","is","a","feature","extraction","mixin","used","to","provide","saving\/loading","functionality","for","sequential","and","image","feature","extractors","."]
docstr: Save a feature_extractor object to the directory `save_directory`, so that it can be re-loaded using the
  [`~feature_extraction_utils.FeatureExtractionMixin.from_pretrained`] class method.
  
  Args:
      save_directory (`str` or `os.PathLike`):
          Directory where the feature extractor 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 (`Dict[str, Any]`, *optional*):
          Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
docstr_tok: ["Save","a","feature_extractor","object","to","the","directory","`","save_directory","`",",","so","that","it","can","be","re-loaded","using","the","[","`","~feature_extraction_utils.FeatureExtractionMixin.from_pretrained","`","]","class","method",".","Args",":","save_directory","(","`","str","`","or","`","os.PathLike","`",")",":","Directory","where","the","feature","extractor","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","(","`","Dict","[","str",",","Any","]","`",",","*","optional","*",")",":","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 feature_extractor object to the directory `save_directory`, so that it can be re-loaded using the
      [`~feature_extraction_utils.FeatureExtractionMixin.from_pretrained`] class method.
  
      Args:
          save_directory (`str` or `os.PathLike`):
              Directory where the feature extractor 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 (`Dict[str, Any]`, *optional*):
              Additional key word arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
      """
      use_auth_token = kwargs.pop("use_auth_token", None)
  
      if use_auth_token is not None:
          warnings.warn(
              "The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
              FutureWarning,
          )
          if kwargs.get("token", None) is not None:
              raise ValueError(
                  "`token` and `use_auth_token` are both specified. Please set only the argument `token`."
              )
          kwargs["token"] = use_auth_token
  
      if os.path.isfile(save_directory):
          raise AssertionError(
              f"Provided path ({save_directory}) should be a directory, not a file"
          )
  
      os.makedirs(save_directory, exist_ok=True)
  
      if push_to_hub:
          commit_message = kwargs.pop("commit_message", None)
          repo_id = kwargs.pop(
              "repo_id", save_directory.split(os.path.sep)[-1]
          )
          repo_id = self._create_repo(repo_id, **kwargs)
          files_timestamps = self._get_files_timestamps(save_directory)
  
      # 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_feature_extractor_file = os.path.join(
          save_directory, FEATURE_EXTRACTOR_NAME
      )
  
      self.to_json_file(output_feature_extractor_file)
      logger.info(
          f"Feature extractor saved in {output_feature_extractor_file}"
      )
  
      if push_to_hub:
          self._upload_modified_files(
              save_directory,
              repo_id,
              files_timestamps,
              commit_message=commit_message,
              token=kwargs.get("token"),
          )
  
      return [output_feature_extractor_file]
  
imports: import copy
  import json
  import os
  import warnings
  from collections import UserDict
  from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Union
  import numpy
  from .dynamic_module_utils import custom_object_save
  from .utils import FEATURE_EXTRACTOR_NAME, PushToHubMixin, TensorType, add_model_info_to_auto_map, cached_file, copy_func, download_url, is_flax_available, is_jax_tensor, is_numpy_array, is_offline_mode, is_remote_url, is_tf_available, is_torch_available, is_torch_device, is_torch_dtype, logging, requires_backends
label_desc: Use image node_id 4 for calling the FeatureExtractionMixin obj's underlying member method code with example usage: obj.save_pretrained(save_directory, push_to_hub) and returns: list