




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

from packaging import version


__lowerCAmelCase :Dict     =    {
    '<': operator.lt,
    '<=': operator.le,
    '==': operator.eq,
    '!=': operator.ne,
    '>=': operator.ge,
    '>': operator.gt,
}







def    A				(							UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase				):




					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(__a				)  ,  version.parse(__a				)				):
										raise ImportError(
										    F"""{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}"""				)







def    A				(							UpperCAmelCase  ,  UpperCAmelCase = None				):
					_snake_case       :					Optional[int]				       =   F"""\n{hint}""" if hint is not None else ""

					# non-versioned check
					if re.match(R"^[\w_\-\d]+$"  ,  __a				):
										_snake_case       , _snake_case       , _snake_case       :					Tuple				       =   requirement, None, None
					else:
										_snake_case       :					Any				       =   re.findall(R"^([^!=<>\s]+)([\s!=<>]{1,2}.+)"  ,  __a				)
										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}"""				)
										_snake_case       , _snake_case       :					Any				       =   match[0]
										_snake_case       :					Dict				       =   want_full.split(","				)  # there could be multiple requirements
										_snake_case       :					Optional[Any]				       =   {}
										for w in want_range:
															_snake_case       :					str				       =   re.findall(R"^([\s!=<>]{1,2})(.+)"  ,  __a				)
															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}"""				)
															_snake_case       , _snake_case       :					Tuple				       =   match[0]
															_snake_case       :					Optional[Any]				       =   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":
										_snake_case       :					Union[str, Any]				       =   ".".join([str(__a				) for x in sys.version_info[:3]]				)
										for op, want_ver in wanted.items():
															_compare_versions(__a  ,  __a  ,  __a  ,  __a  ,  __a  ,  __a				)
										return

					# check if any version is installed
					try:
										_snake_case       :					Dict				       =   importlib.metadata.version(__a				)
					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(__a  ,  __a  ,  __a  ,  __a  ,  __a  ,  __a				)







def    A				(							UpperCAmelCase				):
					_snake_case       :					int				       =   "Try: pip install transformers -U or pip install -e '.[dev]' if you're working with git main"
					return require_version(__a  ,  __a				)






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__lowerCAmelCase :str     =    {
    'configuration_nllb_moe': [
        'NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'NllbMoeConfig',
    ]
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__lowerCAmelCase :Optional[int]     =    [
							    'NLLB_MOE_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'NllbMoeForConditionalGeneration',
							    'NllbMoeModel',
							    'NllbMoePreTrainedModel',
							    'NllbMoeTop2Router',
							    'NllbMoeSparseMLP',
							]


if TYPE_CHECKING:
							from .configuration_nllb_moe import (
							    NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP,
							    NllbMoeConfig,
							)

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_nllb_moe import (
														    NLLB_MOE_PRETRAINED_MODEL_ARCHIVE_LIST,
														    NllbMoeForConditionalGeneration,
														    NllbMoeModel,
														    NllbMoePreTrainedModel,
														    NllbMoeSparseMLP,
														    NllbMoeTopaRouter,
														)


else:
							import sys

							__lowerCAmelCase :int     =    _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)