


'''simple docstring'''







from typing import TYPE_CHECKING

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


_SCREAMING_SNAKE_CASE       :   int        = {
    "configuration_utils": ["GenerationConfig"],
    "streamers": ["TextIteratorStreamer", "TextStreamer"],
}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_SCREAMING_SNAKE_CASE       :   List[str]        = [
		    "Constraint",
		    "ConstraintListState",
		    "DisjunctiveConstraint",
		    "PhrasalConstraint",
		]
		_SCREAMING_SNAKE_CASE       :   List[str]        = [
		    "BeamHypotheses",
		    "BeamScorer",
		    "BeamSearchScorer",
		    "ConstrainedBeamSearchScorer",
		]
		_SCREAMING_SNAKE_CASE       :   Tuple        = [
		    "EpsilonLogitsWarper",
		    "EtaLogitsWarper",
		    "ForcedBOSTokenLogitsProcessor",
		    "ForcedEOSTokenLogitsProcessor",
		    "HammingDiversityLogitsProcessor",
		    "InfNanRemoveLogitsProcessor",
		    "LogitsProcessor",
		    "LogitsProcessorList",
		    "LogitsWarper",
		    "MinLengthLogitsProcessor",
		    "MinNewTokensLengthLogitsProcessor",
		    "NoBadWordsLogitsProcessor",
		    "NoRepeatNGramLogitsProcessor",
		    "PrefixConstrainedLogitsProcessor",
		    "RepetitionPenaltyLogitsProcessor",
		    "SequenceBiasLogitsProcessor",
		    "EncoderRepetitionPenaltyLogitsProcessor",
		    "TemperatureLogitsWarper",
		    "TopKLogitsWarper",
		    "TopPLogitsWarper",
		    "TypicalLogitsWarper",
		    "EncoderNoRepeatNGramLogitsProcessor",
		    "ExponentialDecayLengthPenalty",
		    "LogitNormalization",
		]
		_SCREAMING_SNAKE_CASE       :   Dict        = [
		    "MaxNewTokensCriteria",
		    "MaxLengthCriteria",
		    "MaxTimeCriteria",
		    "StoppingCriteria",
		    "StoppingCriteriaList",
		    "validate_stopping_criteria",
		]
		_SCREAMING_SNAKE_CASE       :   str        = [
		    "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:
		_SCREAMING_SNAKE_CASE       :   List[Any]        = [
		    "TFForcedBOSTokenLogitsProcessor",
		    "TFForcedEOSTokenLogitsProcessor",
		    "TFLogitsProcessor",
		    "TFLogitsProcessorList",
		    "TFLogitsWarper",
		    "TFMinLengthLogitsProcessor",
		    "TFNoBadWordsLogitsProcessor",
		    "TFNoRepeatNGramLogitsProcessor",
		    "TFRepetitionPenaltyLogitsProcessor",
		    "TFTemperatureLogitsWarper",
		    "TFTopKLogitsWarper",
		    "TFTopPLogitsWarper",
		    "TFForceTokensLogitsProcessor",
		    "TFSuppressTokensAtBeginLogitsProcessor",
		    "TFSuppressTokensLogitsProcessor",
		]
		_SCREAMING_SNAKE_CASE       :   List[str]        = [
		    "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:
		_SCREAMING_SNAKE_CASE       :   Optional[int]        = [
		    "FlaxForcedBOSTokenLogitsProcessor",
		    "FlaxForcedEOSTokenLogitsProcessor",
		    "FlaxLogitsProcessor",
		    "FlaxLogitsProcessorList",
		    "FlaxLogitsWarper",
		    "FlaxMinLengthLogitsProcessor",
		    "FlaxTemperatureLogitsWarper",
		    "FlaxTopKLogitsWarper",
		    "FlaxTopPLogitsWarper",
		]
		_SCREAMING_SNAKE_CASE       :   str        = [
		    "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

		_SCREAMING_SNAKE_CASE       :   Union[str, Any]        = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



'''simple docstring'''







import unittest
from dataclasses import dataclass
from typing import Optional

from transformers.utils import ModelOutput






@dataclass
class 		_snake_case    (				snake_case_		):






						'''simple docstring'''







						__snake_case   =      42
						__snake_case   =      None
						__snake_case   =      None






class 		_snake_case    (				unittest.TestCase		):






						'''simple docstring'''







						def lowerCAmelCase__ (  self:	List[str]     )							->	str:
										__magic_name__				:					List[Any]						       =       ModelOutputTest(a=30     )
										self.assertEqual(x.a      ,							30     )
										self.assertIsNone(x.b     )
										self.assertIsNone(x.c     )
										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					Optional[int]						       =       x.d







						def lowerCAmelCase__ (  self:	Dict     )							->	Dict:
										__magic_name__				:					List[Any]						       =       ModelOutputTest(a=30      ,							b=10     )
										self.assertEqual(x[0]      ,							30     )
										self.assertEqual(x[1]      ,							10     )
										self.assertEqual(x[:2]      ,							(30, 10)     )
										self.assertEqual(x[:]      ,							(30, 10)     )

										__magic_name__				:					str						       =       ModelOutputTest(a=30      ,							c=10     )
										self.assertEqual(x[0]      ,							30     )
										self.assertEqual(x[1]      ,							10     )
										self.assertEqual(x[:2]      ,							(30, 10)     )
										self.assertEqual(x[:]      ,							(30, 10)     )







						def lowerCAmelCase__ (  self:	List[Any]     )							->	Optional[int]:
										__magic_name__				:					Optional[Any]						       =       ModelOutputTest(a=30      ,							b=10     )
										self.assertEqual(x["a"]      ,							30     )
										self.assertEqual(x["b"]      ,							10     )
										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					str						       =       x["c"]

										__magic_name__				:					Optional[Any]						       =       ModelOutputTest(a=30      ,							c=10     )
										self.assertEqual(x["a"]      ,							30     )
										self.assertEqual(x["c"]      ,							10     )
										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					Union[str, Any]						       =       x["b"]







						def lowerCAmelCase__ (  self:	Optional[Any]     )							->	Any:
										__magic_name__				:					Any						       =       ModelOutputTest(a=30     )
										self.assertEqual(list(x.keys()     )      ,							["a"]     )
										self.assertEqual(list(x.values()     )      ,							[30]     )
										self.assertEqual(list(x.items()     )      ,							[("a", 30)]     )
										self.assertEqual(list(__UpperCamelCase     )      ,							["a"]     )

										__magic_name__				:					Dict						       =       ModelOutputTest(a=30      ,							b=10     )
										self.assertEqual(list(x.keys()     )      ,							["a", "b"]     )
										self.assertEqual(list(x.values()     )      ,							[30, 10]     )
										self.assertEqual(list(x.items()     )      ,							[("a", 30), ("b", 10)]     )
										self.assertEqual(list(__UpperCamelCase     )      ,							["a", "b"]     )

										__magic_name__				:					int						       =       ModelOutputTest(a=30      ,							c=10     )
										self.assertEqual(list(x.keys()     )      ,							["a", "c"]     )
										self.assertEqual(list(x.values()     )      ,							[30, 10]     )
										self.assertEqual(list(x.items()     )      ,							[("a", 30), ("c", 10)]     )
										self.assertEqual(list(__UpperCamelCase     )      ,							["a", "c"]     )

										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					str						       =       x.update({"d": 20}     )
										with self.assertRaises(__UpperCamelCase     ):
														del x["a"]
										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					List[str]						       =       x.pop("a"     )
										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					Optional[Any]						       =       x.setdefault("d"      ,							32     )







						def lowerCAmelCase__ (  self:	Dict     )							->	int:
										__magic_name__				:					Any						       =       ModelOutputTest(a=30     )
										__magic_name__				:					Tuple						       =       10
										self.assertEqual(x.a      ,							10     )
										self.assertEqual(x["a"]      ,							10     )







						def lowerCAmelCase__ (  self:	Dict     )							->	Union[str, Any]:
										__magic_name__				:					Tuple						       =       ModelOutputTest(a=30     )
										__magic_name__				:					Union[str, Any]						       =       10
										self.assertEqual(x.a      ,							10     )
										self.assertEqual(x["a"]      ,							10     )







						def lowerCAmelCase__ (  self:	Optional[int]     )							->	Optional[int]:
										__magic_name__				:					Tuple						       =       ModelOutputTest({"a": 30, "b": 10}     )
										self.assertEqual(list(x.keys()     )      ,							["a", "b"]     )
										self.assertEqual(x.a      ,							30     )
										self.assertEqual(x.b      ,							10     )







						def lowerCAmelCase__ (  self:	Optional[int]     )							->	Optional[Any]:
										__magic_name__				:					List[str]						       =       ModelOutputTest([("a", 30), ("b", 10)]     )
										self.assertEqual(list(x.keys()     )      ,							["a", "b"]     )
										self.assertEqual(x.a      ,							30     )
										self.assertEqual(x.b      ,							10     )

										with self.assertRaises(__UpperCamelCase     ):
														__magic_name__				:					Any						       =       ModelOutputTest([("a", 30), (10, 10)]     )

										__magic_name__				:					Any						       =       ModelOutputTest(a=(30, 30)     )
										self.assertEqual(list(x.keys()     )      ,							["a"]     )
										self.assertEqual(x.a      ,							(30, 30)     )