





"""simple docstring"""





# Lint as: python3
import dataclasses
import re
from dataclasses import dataclass
from functools import total_ordering
from typing import Optional, Union


__A											=						re.compile(R"""^(?P<major>\d+)""" R"""\.(?P<minor>\d+)""" R"""\.(?P<patch>\d+)$""")






@total_ordering
@dataclass
class    _lowerCAmelCase  :
       """simple docstring"""




       __magic_name__	:str
       __magic_name__	:Optional[str]						    =   None
       __magic_name__	:Optional[Union[str, int]]						    =   None
       __magic_name__	:Optional[Union[str, int]]						    =   None
       __magic_name__	:Optional[Union[str, int]]						    =   None






       def 	snake_case		(       self ):



         '''simple docstring'''

         lowerCAmelCase__				,							lowerCAmelCase__				,							lowerCAmelCase__     :Tuple											=				_str_to_version_tuple(self.version_str )






       def __repr__(       self ):



         '''simple docstring'''

         return F"{self.tuple[0]}.{self.tuple[1]}.{self.tuple[2]}"






       @property
       def 	snake_case		(       self ):



         '''simple docstring'''

         return self.major, self.minor, self.patch






       def 	snake_case		(       self       ,					__UpperCAmelCase ):



         '''simple docstring'''

         if isinstance(__UpperCAmelCase       ,					__UpperCAmelCase ):
           return Version(__UpperCAmelCase )
         elif isinstance(__UpperCAmelCase       ,					__UpperCAmelCase ):
           return other
         raise TypeError(F"{other} (type {type(__UpperCAmelCase )}) cannot be compared to version." )






       def __eq__(       self       ,					__UpperCAmelCase ):



         '''simple docstring'''

         try:
           lowerCAmelCase__     :Optional[int]											=				self._validate_operand(__UpperCAmelCase )
         except (TypeError, ValueError):
           return False
         else:
           return self.tuple == other.tuple






       def __lt__(       self       ,					__UpperCAmelCase ):



         '''simple docstring'''

         lowerCAmelCase__     :Union[str, Any]											=				self._validate_operand(__UpperCAmelCase )
         return self.tuple < other.tuple






       def __hash__(       self ):



         '''simple docstring'''

         return hash(_version_tuple_to_str(self.tuple ) )






       @classmethod
       def 	snake_case		(       cls       ,					__UpperCAmelCase ):



         '''simple docstring'''

         lowerCAmelCase__     :List[str]											=				{f.name for f in dataclasses.fields(cls )}
         return cls(**{k: v for k, v in dic.items() if k in field_names} )






       def 	snake_case		(       self ):



         '''simple docstring'''

         return self.version_str






def 					__A  (_SCREAMING_SNAKE_CASE     )   ->Dict:





  """simple docstring"""


  lowerCAmelCase__     :Any											=				_VERSION_REG.match(_SCREAMING_SNAKE_CASE     )
  if not res:
    raise ValueError(F"Invalid version '{version_str}'. Format should be x.y.z with {{x,y,z}} being digits."     )
  return tuple(int(_SCREAMING_SNAKE_CASE     ) for v in [res.group('major'     ), res.group('minor'     ), res.group('patch'     )]     )




def 					__A  (_SCREAMING_SNAKE_CASE     )   ->int:





  """simple docstring"""


  return ".".join(str(_SCREAMING_SNAKE_CASE     ) for v in version_tuple     )







"""simple docstring"""





import importlib.metadata
import operator
import re
import sys
from typing import Optional

from packaging import version


__A											=						{
    """<""": operator.lt,
    """<=""": operator.le,
    """==""": operator.eq,
    """!=""": operator.ne,
    """>=""": operator.ge,
    """>""": operator.gt,
}
def 					__A  (_SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE     )   ->Union[str, Any]:





  """simple docstring"""


  if got_ver is None or want_ver is None:
    raise ValueError(
        F"Unable to compare versions for {requirement}: need={want_ver} found={got_ver}. This is unusual. Consider"
        F" reinstalling {pkg}."     )
  if not ops[op](version.parse(_SCREAMING_SNAKE_CASE     )	,  version.parse(_SCREAMING_SNAKE_CASE     )     ):
    raise ImportError(
        F"{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}"     )
def 					__A  (_SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE = None     )   ->None:





  """simple docstring"""


  lowerCAmelCase__     :List[str]											=				F"\n{hint}" if hint is not None else ''

  # non-versioned check
  if re.match(r'^[\w_\-\d]+$'	,  _SCREAMING_SNAKE_CASE     ):
    lowerCAmelCase__				,							lowerCAmelCase__				,							lowerCAmelCase__     :Any											=				requirement, None, None
  else:
    lowerCAmelCase__     :List[str]											=				re.findall(r'^([^!=<>\s]+)([\s!=<>]{1,2}.+)'	,  _SCREAMING_SNAKE_CASE     )
    if not match:
      raise ValueError(
          'requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23, but'
          F" got {requirement}"     )
    lowerCAmelCase__				,							lowerCAmelCase__     :Union[str, Any]											=				match[0]
    lowerCAmelCase__     :List[Any]											=				want_full.split(','     )  # there could be multiple requirements
    lowerCAmelCase__     :Any											=				{}
    for w in want_range:
      lowerCAmelCase__     :Tuple											=				re.findall(r'^([\s!=<>]{1,2})(.+)'	,  _SCREAMING_SNAKE_CASE     )
      if not match:
        raise ValueError(
            'requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23,'
            F" but got {requirement}"     )
      lowerCAmelCase__				,							lowerCAmelCase__     :int											=				match[0]
      lowerCAmelCase__     :str											=				want_ver
      if op not in ops:
        raise ValueError(F"{requirement}: need one of {list(ops.keys()     )}, but got {op}"     )

    # special case
  if pkg == "python":
    lowerCAmelCase__     :Any											=				'.'.join([str(_SCREAMING_SNAKE_CASE     ) for x in sys.version_info[:3]]     )
    for op, want_ver in wanted.items():
      _compare_versions(_SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE     )
    return

  # check if any version is installed
  try:
    lowerCAmelCase__     :List[Any]											=				importlib.metadata.version(_SCREAMING_SNAKE_CASE     )
  except importlib.metadata.PackageNotFoundError:
    raise importlib.metadata.PackageNotFoundError(
        F"The '{requirement}' distribution was not found and is required by this application. {hint}"     )

  # check that the right version is installed if version number or a range was provided
  if want_ver is not None:
    for op, want_ver in wanted.items():
      _compare_versions(_SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE     )




def 					__A  (_SCREAMING_SNAKE_CASE     )   ->List[Any]:





  """simple docstring"""


  lowerCAmelCase__     :Optional[Any]											=				'Try: pip install transformers -U or pip install -e \'.[dev]\' if you\'re working with git main'
  return require_version(_SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE     )
