

'''simple docstring'''







from importlib import import_module

from .logging import get_logger


__lowerCamelCase		       =    get_logger(__name__)


class 					A__      :



    def __init__(					self		,				UpperCamelCase__		,				UpperCamelCase__=None       )						->      List[Any]:





           '''simple docstring'''
           A_						=      attrs or []
           if module is not None:
                  for key in module.__dict__:
                         if key in attrs or not key.startswith("""__"""       ):
                                setattr(self		,				UpperCamelCase__		,				getattr(UpperCamelCase__		,				UpperCamelCase__       )       )
           A_						=      module._original_module if isinstance(UpperCamelCase__		,				_PatchedModuleObj       ) else module


class 					A__      :
    lowercase						=		[]



    def __init__(					self		,				UpperCamelCase__		,				UpperCamelCase__		,				UpperCamelCase__		,				UpperCamelCase__=None       )						->      str:





           '''simple docstring'''
           A_						=      obj
           A_						=      target
           A_						=      new
           A_						=      target.split("""."""       )[0]
           A_						=      {}
           A_						=      attrs or []



    def __enter__(					self       )						->      List[Any]:





           '''simple docstring'''
           *A_					,			A_						=      self.target.split("""."""       )

           # Patch modules:
           # it's used to patch attributes of submodules like "os.path.join";
           # in this case we need to patch "os" and "os.path"

           for i in range(len(UpperCamelCase__       )       ):
                  try:
                         A_						=      import_module(""".""".join(submodules[: i + 1]       )       )
                  except ModuleNotFoundError:
                         continue
                  # We iterate over all the globals in self.obj in case we find "os" or "os.path"
                  for attr in self.obj.__dir__():
                         A_						=      getattr(self.obj		,				UpperCamelCase__       )
                         # We don't check for the name of the global, but rather if its value *is* "os" or "os.path".
                         # This allows to patch renamed modules like "from os import path as ospath".
                         if obj_attr is submodule or (
                             (isinstance(UpperCamelCase__		,				_PatchedModuleObj       ) and obj_attr._original_module is submodule)
                         ):
                                A_						=      obj_attr
                                # patch at top level
                                setattr(self.obj		,				UpperCamelCase__		,				_PatchedModuleObj(UpperCamelCase__		,				attrs=self.attrs       )       )
                                A_						=      getattr(self.obj		,				UpperCamelCase__       )
                                # construct lower levels patches
                                for key in submodules[i + 1 :]:
                                       setattr(UpperCamelCase__		,				UpperCamelCase__		,				_PatchedModuleObj(getattr(UpperCamelCase__		,				UpperCamelCase__		,				UpperCamelCase__       )		,				attrs=self.attrs       )       )
                                       A_						=      getattr(UpperCamelCase__		,				UpperCamelCase__       )
                                # finally set the target attribute
                                setattr(UpperCamelCase__		,				UpperCamelCase__		,				self.new       )

        # Patch attribute itself:
        # it's used for builtins like "open",
        # and also to patch "os.path.join" we may also need to patch "join"
        # itself if it was imported as "from os.path import join".

           if submodules:  # if it's an attribute of a submodule like "os.path.join"
                  try:
                         A_						=      getattr(import_module(""".""".join(UpperCamelCase__       )       )		,				UpperCamelCase__       )
                  except (AttributeError, ModuleNotFoundError):
                         return
                  # We iterate over all the globals in self.obj in case we find "os.path.join"
                  for attr in self.obj.__dir__():
                         # We don't check for the name of the global, but rather if its value *is* "os.path.join".
                         # This allows to patch renamed attributes like "from os.path import join as pjoin".
                         if getattr(self.obj		,				UpperCamelCase__       ) is attr_value:
                                A_						=      getattr(self.obj		,				UpperCamelCase__       )
                                setattr(self.obj		,				UpperCamelCase__		,				self.new       )
           elif target_attr in globals()["__builtins__"]:  # if it'a s builtin like "open"
                  A_						=      globals()["""__builtins__"""][target_attr]
                  setattr(self.obj		,				UpperCamelCase__		,				self.new       )
           else:
                  raise RuntimeError(f'''Tried to patch attribute {target_attr} instead of a submodule.'''       )



    def __exit__(					self		,				*UpperCamelCase__       )						->      Optional[int]:





           '''simple docstring'''
           for attr in list(self.original       ):
                  setattr(self.obj		,				UpperCamelCase__		,				self.original.pop(UpperCamelCase__       )       )



    def 					snake_case_			(					self       )						->      str:





           '''simple docstring'''
           self.__enter__()
           self._active_patches.append(self       )







    def 					snake_case_			(					self       )						->      Tuple:





           '''simple docstring'''
           try:
                  self._active_patches.remove(self       )
           except ValueError:
                  # If the patch hasn't been started this will fail
                  return None

           return self.__exit__()



'''simple docstring'''







import warnings

from ...utils import logging
from .image_processing_beit import BeitImageProcessor


__lowerCamelCase		       =    logging.get_logger(__name__)


class 					A__      (      _snake_case			):



    def __init__(					self		,				*UpperCamelCase__		,				**UpperCamelCase__       )						->      None:





           '''simple docstring'''
           warnings.warn(
               """The class BeitFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"""
               """ use BeitImageProcessor instead."""		,				UpperCamelCase__		,				)
           super().__init__(*UpperCamelCase__		,				**UpperCamelCase__       )
