




from importlib import import_module

from .logging import get_logger


_A     =			get_logger(__name__)


class  A		:



		def __init__(     self,	UpperCamelCase__,	UpperCamelCase__=None   ):







								"""simple docstring"""



								lowerCAmelCase_      			=  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__   )   )
								lowerCAmelCase_      			=  module._original_module if isinstance(UpperCamelCase__,	_PatchedModuleObj   ) else module







class  A		:
		__snake_case									=   []



		def __init__(     self,	UpperCamelCase__,	UpperCamelCase__,	UpperCamelCase__,	UpperCamelCase__=None   ):







								"""simple docstring"""



								lowerCAmelCase_      			=  obj
								lowerCAmelCase_      			=  target
								lowerCAmelCase_      			=  new
								lowerCAmelCase_      			=  target.split('''.'''   )[0]
								lowerCAmelCase_      			=  {}
								lowerCAmelCase_      			=  attrs or []



		def __enter__(     self   ):







								"""simple docstring"""



								*lowerCAmelCase_			,					lowerCAmelCase_      			=  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:
																				lowerCAmelCase_      			=  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__():
																				lowerCAmelCase_      			=  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)
																				):
																										lowerCAmelCase_      			=  obj_attr
																										# patch at top level
																										setattr(self.obj,	UpperCamelCase__,	_PatchedModuleObj(UpperCamelCase__,	attrs=self.attrs   )   )
																										lowerCAmelCase_      			=  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   )   )
																																lowerCAmelCase_      			=  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:
																				lowerCAmelCase_      			=  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:
																										lowerCAmelCase_      			=  getattr(self.obj,	UpperCamelCase__   )
																										setattr(self.obj,	UpperCamelCase__,	self.new   )
								elif target_attr in globals()["__builtins__"]:  # if it'a s builtin like "open"
														lowerCAmelCase_      			=  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__   ):







								"""simple docstring"""



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



		def        SCREAMING_SNAKE_CASE__			(     self   ):







								"""simple docstring"""



								self.__enter__()
								self._active_patches.append(self   )







		def        SCREAMING_SNAKE_CASE__			(     self   ):







								"""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__()










import warnings

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


_A     =			logging.get_logger(__name__)


class  A		(  __UpperCAmelCase     ):



		def __init__(     self,	*UpperCamelCase__,	**UpperCamelCase__   ):







								"""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__   )




