





import importlib.metadata
import sys

from transformers.testing_utils import TestCasePlus
from transformers.utils.versions import require_version, require_version_core


_lowerCamelCase							=     importlib.metadata.version('numpy')
_lowerCamelCase							=     '.'.join([str(x) for x in sys.version_info[:3]])




class 					UpperCamelCase_    (       UpperCamelCase__      ):


							def        _snake_case					(							self      :int						)				->				int:



									"""simple docstring"""



									require_version_core("""numpy<1000.4.5"""						)
									require_version_core("""numpy<1000.4"""						)
									require_version_core("""numpy<1000"""						)

									# le
									require_version_core("""numpy<=1000.4.5"""						)
									require_version_core(f'''numpy<={numpy_ver}'''						)

									# eq
									require_version_core(f'''numpy=={numpy_ver}'''						)

									# ne
									require_version_core("""numpy!=1000.4.5"""						)

									# ge
									require_version_core("""numpy>=1.0"""						)
									require_version_core("""numpy>=1.0.0"""						)
									require_version_core(f'''numpy>={numpy_ver}'''						)

									# gt
									require_version_core("""numpy>1.0.0"""						)

									# mix
									require_version_core("""numpy>1.0.0,<1000"""						)

									# requirement w/o version
									require_version_core("""numpy"""						)

									# unmet requirements due to version conflict
									for req in ["numpy==1.0.0", "numpy>=1000.0.0", f'''numpy<{numpy_ver}''']:
											try:
													require_version_core(__A						)
											except ImportError as e:
													self.assertIn(f'''{req} is required'''							,			str(__A						)						)
													self.assertIn("""but found"""							,			str(__A						)						)

        # unmet requirements due to missing module
									for req in ["numpipypie>1", "numpipypie2"]:
											try:
													require_version_core(__A						)
											except importlib.metadata.PackageNotFoundError as e:
													self.assertIn(f'''The \'{req}\' distribution was not found and is required by this application'''							,			str(__A						)						)
													self.assertIn("""Try: pip install transformers -U"""							,			str(__A						)						)

        # bogus requirements formats:
        # 1. whole thing
									for req in ["numpy??1.0.0", "numpy1.0.0"]:
											try:
													require_version_core(__A						)
											except ValueError as e:
													self.assertIn("""requirement needs to be in the pip package format"""							,			str(__A						)						)
        # 2. only operators
									for req in ["numpy=1.0.0", "numpy == 1.00", "numpy<>1.0.0", "numpy><1.00", "numpy>>1.0.0"]:
											try:
													require_version_core(__A						)
											except ValueError as e:
													self.assertIn("""need one of """							,			str(__A						)						)


							def        _snake_case					(							self      :Optional[Any]						)				->				Tuple:



									"""simple docstring"""



									require_version("""python>=3.6.0"""						)

									# not matching requirements
									for req in ["python>9.9.9", "python<3.0.0"]:
											try:
													require_version_core(__A						)
											except ImportError as e:
													self.assertIn(f'''{req} is required'''							,			str(__A						)						)
													self.assertIn(f'''but found python=={python_ver}'''							,			str(__A						)						)






from typing import TYPE_CHECKING

from ..utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available


_lowerCamelCase							=     {
    'configuration_utils': ['GenerationConfig'],
    'streamers': ['TextIteratorStreamer', 'TextStreamer'],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowerCamelCase							=     [
	    'Constraint',
	    'ConstraintListState',
	    'DisjunctiveConstraint',
	    'PhrasalConstraint',
	]
	_lowerCamelCase							=     [
	    'BeamHypotheses',
	    'BeamScorer',
	    'BeamSearchScorer',
	    'ConstrainedBeamSearchScorer',
	]
	_lowerCamelCase							=     [
	    'EpsilonLogitsWarper',
	    'EtaLogitsWarper',
	    'ForcedBOSTokenLogitsProcessor',
	    'ForcedEOSTokenLogitsProcessor',
	    'HammingDiversityLogitsProcessor',
	    'InfNanRemoveLogitsProcessor',
	    'LogitsProcessor',
	    'LogitsProcessorList',
	    'LogitsWarper',
	    'MinLengthLogitsProcessor',
	    'MinNewTokensLengthLogitsProcessor',
	    'NoBadWordsLogitsProcessor',
	    'NoRepeatNGramLogitsProcessor',
	    'PrefixConstrainedLogitsProcessor',
	    'RepetitionPenaltyLogitsProcessor',
	    'SequenceBiasLogitsProcessor',
	    'EncoderRepetitionPenaltyLogitsProcessor',
	    'TemperatureLogitsWarper',
	    'TopKLogitsWarper',
	    'TopPLogitsWarper',
	    'TypicalLogitsWarper',
	    'EncoderNoRepeatNGramLogitsProcessor',
	    'ExponentialDecayLengthPenalty',
	    'LogitNormalization',
	]
	_lowerCamelCase							=     [
	    'MaxNewTokensCriteria',
	    'MaxLengthCriteria',
	    'MaxTimeCriteria',
	    'StoppingCriteria',
	    'StoppingCriteriaList',
	    'validate_stopping_criteria',
	]
	_lowerCamelCase							=     [
	    'GenerationMixin',
	    'top_k_top_p_filtering',
	    'GreedySearchEncoderDecoderOutput',
	    'GreedySearchDecoderOnlyOutput',
	    'SampleEncoderDecoderOutput',
	    'SampleDecoderOnlyOutput',
	    'BeamSearchEncoderDecoderOutput',
	    'BeamSearchDecoderOnlyOutput',
	    'BeamSampleEncoderDecoderOutput',
	    'BeamSampleDecoderOnlyOutput',
	    'ContrastiveSearchEncoderDecoderOutput',
	    'ContrastiveSearchDecoderOnlyOutput',
	]

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowerCamelCase							=     [
	    'TFForcedBOSTokenLogitsProcessor',
	    'TFForcedEOSTokenLogitsProcessor',
	    'TFLogitsProcessor',
	    'TFLogitsProcessorList',
	    'TFLogitsWarper',
	    'TFMinLengthLogitsProcessor',
	    'TFNoBadWordsLogitsProcessor',
	    'TFNoRepeatNGramLogitsProcessor',
	    'TFRepetitionPenaltyLogitsProcessor',
	    'TFTemperatureLogitsWarper',
	    'TFTopKLogitsWarper',
	    'TFTopPLogitsWarper',
	    'TFForceTokensLogitsProcessor',
	    'TFSuppressTokensAtBeginLogitsProcessor',
	    'TFSuppressTokensLogitsProcessor',
	]
	_lowerCamelCase							=     [
	    'TFGenerationMixin',
	    'tf_top_k_top_p_filtering',
	    'TFGreedySearchDecoderOnlyOutput',
	    'TFGreedySearchEncoderDecoderOutput',
	    'TFSampleEncoderDecoderOutput',
	    'TFSampleDecoderOnlyOutput',
	    'TFBeamSearchEncoderDecoderOutput',
	    'TFBeamSearchDecoderOnlyOutput',
	    'TFBeamSampleEncoderDecoderOutput',
	    'TFBeamSampleDecoderOnlyOutput',
	    'TFContrastiveSearchEncoderDecoderOutput',
	    'TFContrastiveSearchDecoderOnlyOutput',
	]

try:
	if not is_flax_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowerCamelCase							=     [
	    'FlaxForcedBOSTokenLogitsProcessor',
	    'FlaxForcedEOSTokenLogitsProcessor',
	    'FlaxLogitsProcessor',
	    'FlaxLogitsProcessorList',
	    'FlaxLogitsWarper',
	    'FlaxMinLengthLogitsProcessor',
	    'FlaxTemperatureLogitsWarper',
	    'FlaxTopKLogitsWarper',
	    'FlaxTopPLogitsWarper',
	]
	_lowerCamelCase							=     [
	    'FlaxGenerationMixin',
	    'FlaxGreedySearchOutput',
	    'FlaxSampleOutput',
	    'FlaxBeamSearchOutput',
	]

if TYPE_CHECKING:
	from .configuration_utils import GenerationConfig
	from .streamers import TextIteratorStreamer, TextStreamer

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .beam_constraints import Constraint, ConstraintListState, DisjunctiveConstraint, PhrasalConstraint
		from .beam_search import BeamHypotheses, BeamScorer, BeamSearchScorer, ConstrainedBeamSearchScorer
		from .logits_process import (
		    EncoderNoRepeatNGramLogitsProcessor,
		    EncoderRepetitionPenaltyLogitsProcessor,
		    EpsilonLogitsWarper,
		    EtaLogitsWarper,
		    ExponentialDecayLengthPenalty,
		    ForcedBOSTokenLogitsProcessor,
		    ForcedEOSTokenLogitsProcessor,
		    HammingDiversityLogitsProcessor,
		    InfNanRemoveLogitsProcessor,
		    LogitNormalization,
		    LogitsProcessor,
		    LogitsProcessorList,
		    LogitsWarper,
		    MinLengthLogitsProcessor,
		    MinNewTokensLengthLogitsProcessor,
		    NoBadWordsLogitsProcessor,
		    NoRepeatNGramLogitsProcessor,
		    PrefixConstrainedLogitsProcessor,
		    RepetitionPenaltyLogitsProcessor,
		    SequenceBiasLogitsProcessor,
		    TemperatureLogitsWarper,
		    TopKLogitsWarper,
		    TopPLogitsWarper,
		    TypicalLogitsWarper,
		)
		from .stopping_criteria import (
		    MaxLengthCriteria,
		    MaxNewTokensCriteria,
		    MaxTimeCriteria,
		    StoppingCriteria,
		    StoppingCriteriaList,
		    validate_stopping_criteria,
		)
		from .utils import (
		    BeamSampleDecoderOnlyOutput,
		    BeamSampleEncoderDecoderOutput,
		    BeamSearchDecoderOnlyOutput,
		    BeamSearchEncoderDecoderOutput,
		    ContrastiveSearchDecoderOnlyOutput,
		    ContrastiveSearchEncoderDecoderOutput,
		    GenerationMixin,
		    GreedySearchDecoderOnlyOutput,
		    GreedySearchEncoderDecoderOutput,
		    SampleDecoderOnlyOutput,
		    SampleEncoderDecoderOutput,
		    top_k_top_p_filtering,
		)

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tf_logits_process import (
		    TFForcedBOSTokenLogitsProcessor,
		    TFForcedEOSTokenLogitsProcessor,
		    TFForceTokensLogitsProcessor,
		    TFLogitsProcessor,
		    TFLogitsProcessorList,
		    TFLogitsWarper,
		    TFMinLengthLogitsProcessor,
		    TFNoBadWordsLogitsProcessor,
		    TFNoRepeatNGramLogitsProcessor,
		    TFRepetitionPenaltyLogitsProcessor,
		    TFSuppressTokensAtBeginLogitsProcessor,
		    TFSuppressTokensLogitsProcessor,
		    TFTemperatureLogitsWarper,
		    TFTopKLogitsWarper,
		    TFTopPLogitsWarper,
		)
		from .tf_utils import (
		    TFBeamSampleDecoderOnlyOutput,
		    TFBeamSampleEncoderDecoderOutput,
		    TFBeamSearchDecoderOnlyOutput,
		    TFBeamSearchEncoderDecoderOutput,
		    TFContrastiveSearchDecoderOnlyOutput,
		    TFContrastiveSearchEncoderDecoderOutput,
		    TFGenerationMixin,
		    TFGreedySearchDecoderOnlyOutput,
		    TFGreedySearchEncoderDecoderOutput,
		    TFSampleDecoderOnlyOutput,
		    TFSampleEncoderDecoderOutput,
		    tf_top_k_top_p_filtering,
		)

	try:
		if not is_flax_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .flax_logits_process import (
		    FlaxForcedBOSTokenLogitsProcessor,
		    FlaxForcedEOSTokenLogitsProcessor,
		    FlaxLogitsProcessor,
		    FlaxLogitsProcessorList,
		    FlaxLogitsWarper,
		    FlaxMinLengthLogitsProcessor,
		    FlaxTemperatureLogitsWarper,
		    FlaxTopKLogitsWarper,
		    FlaxTopPLogitsWarper,
		)
		from .flax_utils import FlaxBeamSearchOutput, FlaxGenerationMixin, FlaxGreedySearchOutput, FlaxSampleOutput
else:
	import sys

	_lowerCamelCase							=     _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)