




"""simple docstring"""


from importlib import import_module

from .logging import get_logger


A_      =    get_logger(__name__)






class  lowercase:







 '''simple docstring'''





 def __init__(    self:		List[str],				a_:		int,				a_:		Optional[int]=None		):




   '''simple docstring'''



   _snake_case							:		Dict								=  attrs or []
   if module is not None:
     for key in module.__dict__:
       if key in attrs or not key.startswith("""__"""		):
         setattr(self,				a_,				getattr(a_,				a_		)		)
   _snake_case							:		Union[str, Any]								=  module._original_module if isinstance(a_,				_PatchedModuleObj		) else module







class  lowercase:







 '''simple docstring'''





 lowercase__			 = []


 def __init__(    self:		Optional[int],				a_:		Dict,				a_:		List[str],				a_:		int,				a_:		str=None		):




   '''simple docstring'''



   _snake_case							:		List[str]								=  obj
   _snake_case							:		str								=  target
   _snake_case							:		Union[str, Any]								=  new
   _snake_case							:		int								=  target.split("""."""		)[0]
   _snake_case							:		Union[str, Any]								=  {}
   _snake_case							:		str								=  attrs or []


 def __enter__(    self:		str		):




   '''simple docstring'''



   *_snake_case		, _snake_case							:		List[str]								=  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(a_		)		):
     try:
       _snake_case							:		List[Any]								=  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__():
       _snake_case							:		List[Any]								=  getattr(self.obj,				a_		)
       # 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(a_,				_PatchedModuleObj		) and obj_attr._original_module is submodule)
       ):
         _snake_case							:		str								=  obj_attr
         # patch at top level
         setattr(self.obj,				a_,				_PatchedModuleObj(a_,				attrs=self.attrs		)		)
         _snake_case							:		Optional[Any]								=  getattr(self.obj,				a_		)
         # construct lower levels patches
         for key in submodules[i + 1 :]:
           setattr(a_,				a_,				_PatchedModuleObj(getattr(a_,				a_,				a_		),				attrs=self.attrs		)		)
           _snake_case							:		Optional[int]								=  getattr(a_,				a_		)
         # finally set the target attribute
         setattr(a_,				a_,				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:
       _snake_case							:		Optional[int]								=  getattr(import_module(""".""".join(a_		)		),				a_		)
     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,				a_		) is attr_value:
         _snake_case							:		Tuple								=  getattr(self.obj,				a_		)
         setattr(self.obj,				a_,				self.new		)
   elif target_attr in globals()["__builtins__"]:  # if it'a s builtin like "open"
     _snake_case							:		Optional[int]								=  globals()["""__builtins__"""][target_attr]
     setattr(self.obj,				a_,				self.new		)
   else:
     raise RuntimeError(f"Tried to patch attribute {target_attr} instead of a submodule."		)


 def __exit__(    self:		Optional[Any],				*a_:		List[str]		):




   '''simple docstring'''



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


 def 			UpperCamelCase_       (    self:		List[str]		):




   '''simple docstring'''



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


 def 			UpperCamelCase_       (    self:		str		):




   '''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"""


from .data_collator import (
    DataCollatorForLanguageModeling,
    DataCollatorForPermutationLanguageModeling,
    DataCollatorForSeqaSeq,
    DataCollatorForSOP,
    DataCollatorForTokenClassification,
    DataCollatorForWholeWordMask,
    DataCollatorWithPadding,
    DefaultDataCollator,
    default_data_collator,
)
from .metrics import glue_compute_metrics, xnli_compute_metrics
from .processors import (
    DataProcessor,
    InputExample,
    InputFeatures,
    SingleSentenceClassificationProcessor,
    SquadExample,
    SquadFeatures,
    SquadVaProcessor,
    SquadVaProcessor,
    glue_convert_examples_to_features,
    glue_output_modes,
    glue_processors,
    glue_tasks_num_labels,
    squad_convert_examples_to_features,
    xnli_output_modes,
    xnli_processors,
    xnli_tasks_num_labels,
)


