class_docstr: This is an image processor mixin used to provide saving/loading functionality for sequential and image feature
  extractors.
docstr: Instantiate a type of [`~image_processing_utils.ImageProcessingMixin`] from an image processor.
  
  Args:
      pretrained_model_name_or_path (`str` or `os.PathLike`):
          This can be either:
  
          - a string, the *model id* of a pretrained image_processor 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 image processor file saved using the
            [`~image_processing_utils.ImageProcessingMixin.save_pretrained`] method, e.g.,
            `./my_model_directory/`.
          - a path or url to a saved image processor JSON *file*, e.g.,
            `./my_model_directory/preprocessor_config.json`.
      cache_dir (`str` or `os.PathLike`, *optional*):
          Path to a directory in which a downloaded pretrained model image processor should be cached if the
          standard cache should not be used.
      force_download (`bool`, *optional*, defaults to `False`):
          Whether or not to force to (re-)download the image processor files and override the cached versions if
          they exist.
      resume_download (`bool`, *optional*, defaults to `False`):
          Whether or not to delete incompletely received file. Attempts 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.
      token (`str` or `bool`, *optional*):
          The token to use as HTTP bearer authorization for remote files. If `True`, or not specified, will use
          the token generated when running `huggingface-cli login` (stored in `~/.huggingface`).
      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.
  
  
          <Tip>
  
          To test a pull request you made on the Hub, you can pass `revision="refs/pr/<pr_number>".
  
          </Tip>
  
      return_unused_kwargs (`bool`, *optional*, defaults to `False`):
          If `False`, then this function returns just the final image processor object. If `True`, then this
          functions returns a `Tuple(image_processor, unused_kwargs)` where *unused_kwargs* is a dictionary
          consisting of the key/value pairs whose keys are not image processor attributes: i.e., the part of
          `kwargs` which has not been used to update `image_processor` and is otherwise ignored.
      subfolder (`str`, *optional*, defaults to `""`):
          In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
          specify the folder name here.
      kwargs (`Dict[str, Any]`, *optional*):
          The values in kwargs of any keys which are image processor attributes will be used to override the
          loaded values. Behavior concerning key/value pairs whose keys are *not* image processor attributes is
          controlled by the `return_unused_kwargs` keyword parameter.
  
  Returns:
      A image processor of type [`~image_processing_utils.ImageProcessingMixin`].
  
  Examples:
  
  ```python
  # We can't instantiate directly the base class *ImageProcessingMixin* so let's show the examples on a
  # derived class: *CLIPImageProcessor*
  image_processor = CLIPImageProcessor.from_pretrained(
      "openai/clip-vit-base-patch32"
  )  # Download image_processing_config from huggingface.co and cache.
  image_processor = CLIPImageProcessor.from_pretrained(
      "./test/saved_model/"
  )  # E.g. image processor (or model) was saved using *save_pretrained('./test/saved_model/')*
  image_processor = CLIPImageProcessor.from_pretrained("./test/saved_model/preprocessor_config.json")
  image_processor = CLIPImageProcessor.from_pretrained(
      "openai/clip-vit-base-patch32", do_normalize=False, foo=False
  )
  assert image_processor.do_normalize is False
  image_processor, unused_kwargs = CLIPImageProcessor.from_pretrained(
      "openai/clip-vit-base-patch32", do_normalize=False, foo=False, return_unused_kwargs=True
  )
  assert image_processor.do_normalize is False
  assert unused_kwargs == {"foo": False}
  ```
docstr_tok: ["Instantiate","a","type","of","[","`","~image_processing_utils.ImageProcessingMixin","`","]","from","an","image","processor",".","Args",":","pretrained_model_name_or_path","(","`","str","`","or","`","os.PathLike","`",")",":","This","can","be","either",":","-","a","string",",","the","*","model","id","*","of","a","pretrained","image_processor","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","image","processor","file","saved","using","the","[","`","~image_processing_utils.ImageProcessingMixin.save_pretrained","`","]","method",",","e.g.",",","`",".\/my_model_directory\/","`",".","-","a","path","or","url","to","a","saved","image","processor","JSON","*","file","*",",","e.g.",",","`",".\/my_model_directory\/preprocessor_config.json","`",".","cache_dir","(","`","str","`","or","`","os.PathLike","`",",","*","optional","*",")",":","Path","to","a","directory","in","which","a","downloaded","pretrained","model","image","processor","should","be","cached","if","the","standard","cache","should","not","be","used",".","force_download","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","or","not","to","force","to","(","re-",")","download","the","image","processor","files","and","override","the","cached","versions","if","they","exist",".","resume_download","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","or","not","to","delete","incompletely","received","file",".","Attempts","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",".","token","(","`","str","`","or","`","bool","`",",","*","optional","*",")",":","The","token","to","use","as","HTTP","bearer","authorization","for","remote","files",".","If","`","True","`",",","or","not","specified",",","will","use","the","token","generated","when","running","`","huggingface-cli","login","`","(","stored","in","`","~\/.huggingface","`",")",".","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",".","<","Tip",">","To","test","a","pull","request","you","made","on","the","Hub",",","you","can","pass","`","revision=","''","refs\/pr\/","<","pr_number",">","''",".","<","\/Tip",">","return_unused_kwargs","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","If","`","False","`",",","then","this","function","returns","just","the","final","image","processor","object",".","If","`","True","`",",","then","this","functions","returns","a","`","Tuple","(","image_processor",",","unused_kwargs",")","`","where","*","unused_kwargs","*","is","a","dictionary","consisting","of","the","key\/value","pairs","whose","keys","are","not","image","processor","attributes",":","i.e.",",","the","part","of","`","kwargs","`","which","has","not","been","used","to","update","`","image_processor","`","and","is","otherwise","ignored",".","subfolder","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","''","`",")",":","In","case","the","relevant","files","are","located","inside","a","subfolder","of","the","model","repo","on","huggingface.co",",","you","can","specify","the","folder","name","here",".","kwargs","(","`","Dict","[","str",",","Any","]","`",",","*","optional","*",")",":","The","values","in","kwargs","of","any","keys","which","are","image","processor","attributes","will","be","used","to","override","the","loaded","values",".","Behavior","concerning","key\/value","pairs","whose","keys","are","*","not","*","image","processor","attributes","is","controlled","by","the","`","return_unused_kwargs","`","keyword","parameter",".","Returns",":","A","image","processor","of","type","[","`","~image_processing_utils.ImageProcessingMixin","`","]",".","Examples",":","``","`","python","#","We","ca","n't","instantiate","directly","the","base","class","*","ImageProcessingMixin","*","so","let","'s","show","the","examples","on","a","#","derived","class",":","*","CLIPImageProcessor","*","image_processor","=","CLIPImageProcessor.from_pretrained","(","``","openai\/clip-vit-base-patch32","''",")","#","Download","image_processing_config","from","huggingface.co","and","cache",".","image_processor","=","CLIPImageProcessor.from_pretrained","(","``",".\/test\/saved_model\/","''",")","#","E.g",".","image","processor","(","or","model",")","was","saved","using","*","save_pretrained","(","'.\/test\/saved_model\/","'",")","*","image_processor","=","CLIPImageProcessor.from_pretrained","(","``",".\/test\/saved_model\/preprocessor_config.json","''",")","image_processor","=","CLIPImageProcessor.from_pretrained","(","``","openai\/clip-vit-base-patch32","''",",","do_normalize=False",",","foo=False",")","assert","image_processor.do_normalize","is","False","image_processor",",","unused_kwargs","=","CLIPImageProcessor.from_pretrained","(","``","openai\/clip-vit-base-patch32","''",",","do_normalize=False",",","foo=False",",","return_unused_kwargs=True",")","assert","image_processor.do_normalize","is","False","assert","unused_kwargs","==","{","``","foo","''",":","False","}","``","`"]
code: def from_pretrained(
      cls,
      pretrained_model_name_or_path: Union[str, os.PathLike],
      cache_dir: Optional[Union[str, os.PathLike]] = None,
      force_download: bool = False,
      local_files_only: bool = False,
      token: Optional[Union[str, bool]] = None,
      revision: str = "main",
      **kwargs,
  ):
      r"""
      Instantiate a type of [`~image_processing_utils.ImageProcessingMixin`] from an image processor.
  
      Args:
          pretrained_model_name_or_path (`str` or `os.PathLike`):
              This can be either:
  
              - a string, the *model id* of a pretrained image_processor 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 image processor file saved using the
                [`~image_processing_utils.ImageProcessingMixin.save_pretrained`] method, e.g.,
                `./my_model_directory/`.
              - a path or url to a saved image processor JSON *file*, e.g.,
                `./my_model_directory/preprocessor_config.json`.
          cache_dir (`str` or `os.PathLike`, *optional*):
              Path to a directory in which a downloaded pretrained model image processor should be cached if the
              standard cache should not be used.
          force_download (`bool`, *optional*, defaults to `False`):
              Whether or not to force to (re-)download the image processor files and override the cached versions if
              they exist.
          resume_download (`bool`, *optional*, defaults to `False`):
              Whether or not to delete incompletely received file. Attempts 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.
          token (`str` or `bool`, *optional*):
              The token to use as HTTP bearer authorization for remote files. If `True`, or not specified, will use
              the token generated when running `huggingface-cli login` (stored in `~/.huggingface`).
          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.
  
  
              <Tip>
  
              To test a pull request you made on the Hub, you can pass `revision="refs/pr/<pr_number>".
  
              </Tip>
  
          return_unused_kwargs (`bool`, *optional*, defaults to `False`):
              If `False`, then this function returns just the final image processor object. If `True`, then this
              functions returns a `Tuple(image_processor, unused_kwargs)` where *unused_kwargs* is a dictionary
              consisting of the key/value pairs whose keys are not image processor attributes: i.e., the part of
              `kwargs` which has not been used to update `image_processor` and is otherwise ignored.
          subfolder (`str`, *optional*, defaults to `""`):
              In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
              specify the folder name here.
          kwargs (`Dict[str, Any]`, *optional*):
              The values in kwargs of any keys which are image processor attributes will be used to override the
              loaded values. Behavior concerning key/value pairs whose keys are *not* image processor attributes is
              controlled by the `return_unused_kwargs` keyword parameter.
  
      Returns:
          A image processor of type [`~image_processing_utils.ImageProcessingMixin`].
  
      Examples:
  
      ```python
      # We can't instantiate directly the base class *ImageProcessingMixin* so let's show the examples on a
      # derived class: *CLIPImageProcessor*
      image_processor = CLIPImageProcessor.from_pretrained(
          "openai/clip-vit-base-patch32"
      )  # Download image_processing_config from huggingface.co and cache.
      image_processor = CLIPImageProcessor.from_pretrained(
          "./test/saved_model/"
      )  # E.g. image processor (or model) was saved using *save_pretrained('./test/saved_model/')*
      image_processor = CLIPImageProcessor.from_pretrained("./test/saved_model/preprocessor_config.json")
      image_processor = CLIPImageProcessor.from_pretrained(
          "openai/clip-vit-base-patch32", do_normalize=False, foo=False
      )
      assert image_processor.do_normalize is False
      image_processor, unused_kwargs = CLIPImageProcessor.from_pretrained(
          "openai/clip-vit-base-patch32", do_normalize=False, foo=False, return_unused_kwargs=True
      )
      assert image_processor.do_normalize is False
      assert unused_kwargs == {"foo": False}
      ```"""
      kwargs["cache_dir"] = cache_dir
      kwargs["force_download"] = force_download
      kwargs["local_files_only"] = local_files_only
      kwargs["revision"] = revision
  
      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 token is not None:
              raise ValueError(
                  "`token` and `use_auth_token` are both specified. Please set only the argument `token`."
              )
          token = use_auth_token
  
      if token is not None:
          kwargs["token"] = token
  
      image_processor_dict, kwargs = cls.get_image_processor_dict(
          pretrained_model_name_or_path, **kwargs
      )
  
      return cls.from_dict(image_processor_dict, **kwargs)
  
imports: import copy
  import json
  import os
  import warnings
  from io import BytesIO
  from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
  import numpy
  import requests
  from .dynamic_module_utils import custom_object_save
  from .feature_extraction_utils import BatchFeature
  from .image_transforms import center_crop, normalize, rescale
  from .image_utils import ChannelDimension
  from .utils import IMAGE_PROCESSOR_NAME, PushToHubMixin, add_model_info_to_auto_map, cached_file, copy_func, download_url, is_offline_mode, is_remote_url, is_vision_available, logging
label_desc: Use image node_id 3 for calling the ImageProcessingMixin obj's underlying member method code with example usage: obj.from_pretrained(cls, pretrained_model_name_or_path, cache_dir, force_download, local_files_only, token, revision) and returns: cls