




import inspect
import unittest

from transformers import DataaVecVisionConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
	import torch
	from torch import nn

	from transformers import (
	    MODEL_MAPPING,
	    DataaVecVisionForImageClassification,
	    DataaVecVisionForSemanticSegmentation,
	    DataaVecVisionModel,
	)
	from transformers.models.dataavec.modeling_dataavec_vision import DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
	from PIL import Image

	from transformers import BeitImageProcessor


class  lowerCamelCase     :






			'''simple docstring'''





			def __init__(			self      : Dict							,    lowerCamelCase_      : Optional[int]							,    lowerCamelCase_      : int=100							,    lowerCamelCase_      : Union[str, Any]=13							,    lowerCamelCase_      : Union[str, Any]=30							,    lowerCamelCase_      : Tuple=2							,    lowerCamelCase_      : List[Any]=3							,    lowerCamelCase_      : Any=True							,    lowerCamelCase_      : Union[str, Any]=True							,    lowerCamelCase_      : List[Any]=32							,    lowerCamelCase_      : Any=4							,    lowerCamelCase_      : int=4							,    lowerCamelCase_      : Dict=37							,    lowerCamelCase_      : int="gelu"							,    lowerCamelCase_      : Union[str, Any]=0.1							,    lowerCamelCase_      : Tuple=0.1							,    lowerCamelCase_      : List[str]=10							,    lowerCamelCase_      : int=0.0_2							,    lowerCamelCase_      : Any=3							,    lowerCamelCase_      : Any=None							,    lowerCamelCase_      : Optional[int]=[0, 1, 2, 3]							,    )    -> Any:
								__magic_name__				:						Any     				=				parent
								__magic_name__				:						str     				=				100
								__magic_name__				:						int     				=				batch_size
								__magic_name__				:						Optional[Any]     				=				image_size
								__magic_name__				:						Tuple     				=				patch_size
								__magic_name__				:						str     				=				num_channels
								__magic_name__				:						Dict     				=				is_training
								__magic_name__				:						Optional[int]     				=				use_labels
								__magic_name__				:						Dict     				=				hidden_size
								__magic_name__				:						Union[str, Any]     				=				num_hidden_layers
								__magic_name__				:						Optional[int]     				=				num_attention_heads
								__magic_name__				:						Optional[int]     				=				intermediate_size
								__magic_name__				:						str     				=				hidden_act
								__magic_name__				:						Any     				=				hidden_dropout_prob
								__magic_name__				:						List[Any]     				=				attention_probs_dropout_prob
								__magic_name__				:						List[str]     				=				type_sequence_label_size
								__magic_name__				:						Any     				=				initializer_range
								__magic_name__				:						str     				=				scope
								__magic_name__				:						Optional[int]     				=				out_indices
								__magic_name__				:						Any     				=				num_labels

								# in BeiT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
								__magic_name__				:						Any     				=				(image_size // patch_size) ** 2
								__magic_name__				:						List[str]     				=				num_patches + 1

			def 				UpperCAmelCase__							(			self      : List[str]	)    -> Optional[Any]:
								__magic_name__				:						Optional[int]     				=				floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]	)

								__magic_name__				:						List[Any]     				=				None
								__magic_name__				:						Union[str, Any]     				=				None
								if self.use_labels:
													__magic_name__				:						Tuple     				=				ids_tensor([self.batch_size]							,    self.type_sequence_label_size	)
													__magic_name__				:						Optional[int]     				=				ids_tensor([self.batch_size, self.image_size, self.image_size]							,    self.num_labels	)

								__magic_name__				:						int     				=				self.get_config()

								return config, pixel_values, labels, pixel_labels

			def 				UpperCAmelCase__							(			self      : int	)    -> int:
								return DataaVecVisionConfig(
								    vocab_size=self.vocab_size							,    image_size=self.image_size							,    patch_size=self.patch_size							,    num_channels=self.num_channels							,    hidden_size=self.hidden_size							,    num_hidden_layers=self.num_hidden_layers							,    num_attention_heads=self.num_attention_heads							,    intermediate_size=self.intermediate_size							,    hidden_act=self.hidden_act							,    hidden_dropout_prob=self.hidden_dropout_prob							,    attention_probs_dropout_prob=self.attention_probs_dropout_prob							,    is_decoder=lowerCamelCase_							,    initializer_range=self.initializer_range							,    out_indices=self.out_indices							,    )

			def 				UpperCAmelCase__							(			self      : Optional[Any]							,    lowerCamelCase_      : List[Any]							,    lowerCamelCase_      : str							,    lowerCamelCase_      : List[str]							,    lowerCamelCase_      : Tuple	)    -> int:
								__magic_name__				:						List[str]     				=				DataaVecVisionModel(config=lowerCamelCase_	)
								model.to(lowerCamelCase_	)
								model.eval()
								__magic_name__				:						Any     				=				model(lowerCamelCase_	)
								# expected sequence length = num_patches + 1 (we add 1 for the [CLS] token)
								__magic_name__				:						Optional[Any]     				=				(self.image_size // self.patch_size) ** 2
								self.parent.assertEqual(result.last_hidden_state.shape							,    (self.batch_size, num_patches + 1, self.hidden_size)	)

			def 				UpperCAmelCase__							(			self      : Union[str, Any]							,    lowerCamelCase_      : List[Any]							,    lowerCamelCase_      : List[Any]							,    lowerCamelCase_      : List[Any]							,    lowerCamelCase_      : int	)    -> Any:
								__magic_name__				:						List[str]     				=				self.type_sequence_label_size
								__magic_name__				:						int     				=				DataaVecVisionForImageClassification(lowerCamelCase_	)
								model.to(lowerCamelCase_	)
								model.eval()
								__magic_name__				:						List[Any]     				=				model(lowerCamelCase_							,    labels=lowerCamelCase_	)
								self.parent.assertEqual(result.logits.shape							,    (self.batch_size, self.type_sequence_label_size)	)

			def 				UpperCAmelCase__							(			self      : Union[str, Any]							,    lowerCamelCase_      : Optional[int]							,    lowerCamelCase_      : Dict							,    lowerCamelCase_      : List[str]							,    lowerCamelCase_      : Optional[Any]	)    -> Union[str, Any]:
								__magic_name__				:						Dict     				=				self.num_labels
								__magic_name__				:						Tuple     				=				DataaVecVisionForSemanticSegmentation(lowerCamelCase_	)
								model.to(lowerCamelCase_	)
								model.eval()
								__magic_name__				:						List[Any]     				=				model(lowerCamelCase_	)
								self.parent.assertEqual(
								    result.logits.shape							,    (self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)	)
								__magic_name__				:						int     				=				model(lowerCamelCase_							,    labels=lowerCamelCase_	)
								self.parent.assertEqual(
								    result.logits.shape							,    (self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)	)


			def 				UpperCAmelCase__							(			self      : Any	)    -> Dict:
								__magic_name__				:						Optional[int]     				=				self.prepare_config_and_inputs()
								__magic_name__				,     __magic_name__				,     __magic_name__				,     __magic_name__				:						Optional[Any]     				=				config_and_inputs
								__magic_name__				:						Any     				=				{'''pixel_values''': pixel_values}
								return config, inputs_dict






@require_torch
class  lowerCamelCase     (		_lowerCamelCase					,_lowerCamelCase					,unittest.TestCase    ):






			'''simple docstring'''





			UpperCamelCase__										=(
			    (DataaVecVisionModel, DataaVecVisionForImageClassification, DataaVecVisionForSemanticSegmentation)
			    if is_torch_available()
			    else ()
			)
			UpperCamelCase__										=(
			    {
			        '''feature-extraction''': DataaVecVisionModel,
			        '''image-classification''': DataaVecVisionForImageClassification,
			        '''image-segmentation''': DataaVecVisionForSemanticSegmentation,
			    }
			    if is_torch_available()
			    else {}
			)

			UpperCamelCase__										=False
			UpperCamelCase__										=False
			UpperCamelCase__										=False

			def 				UpperCAmelCase__							(			self      : Any	)    -> Optional[int]:
								__magic_name__				:						str     				=				DataaVecVisionModelTester(self	)
								__magic_name__				:						Optional[int]     				=				ConfigTester(
								    self							,    config_class=lowerCamelCase_							,    has_text_modality=lowerCamelCase_							,    hidden_size=37	)

			def 				UpperCAmelCase__							(			self      : Tuple	)    -> List[Any]:
								self.config_tester.run_common_tests()

			def 				UpperCAmelCase__							(			self      : Optional[Any]	)    -> Any:
								# Data2VecVision does not use inputs_embeds
								pass

			@require_torch_multi_gpu
			@unittest.skip(
			    reason='''Data2VecVision has some layers using `add_module` which doesn\'t work well with `nn.DataParallel`'''	)
			def 				UpperCAmelCase__							(			self      : Any	)    -> Dict:
								pass

			def 				UpperCAmelCase__							(			self      : Any	)    -> Optional[int]:
								__magic_name__				,     __magic_name__				:						List[Any]     				=				self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
													__magic_name__				:						List[str]     				=				model_class(lowerCamelCase_	)
													self.assertIsInstance(model.get_input_embeddings()							,    (nn.Module)	)
													__magic_name__				:						str     				=				model.get_output_embeddings()
													self.assertTrue(x is None or isinstance(lowerCamelCase_							,    nn.Linear	)	)

			def 				UpperCAmelCase__							(			self      : Optional[Any]	)    -> Optional[Any]:
								__magic_name__				,     __magic_name__				:						List[str]     				=				self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
													__magic_name__				:						Optional[int]     				=				model_class(lowerCamelCase_	)
													__magic_name__				:						Tuple     				=				inspect.signature(model.forward	)
													# signature.parameters is an OrderedDict => so arg_names order is deterministic
													__magic_name__				:						Optional[int]     				=				[*signature.parameters.keys()]

													__magic_name__				:						Union[str, Any]     				=				['''pixel_values''']
													self.assertListEqual(arg_names[:1]							,    lowerCamelCase_	)

			def 				UpperCAmelCase__							(			self      : List[str]	)    -> Optional[int]:
								__magic_name__				:						Optional[int]     				=				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*lowerCamelCase_	)

			def 				UpperCAmelCase__							(			self      : List[Any]	)    -> List[str]:
								__magic_name__				:						List[str]     				=				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_image_segmentation(*lowerCamelCase_	)

			def 				UpperCAmelCase__							(			self      : List[str]	)    -> Dict:
								if not self.model_tester.is_training:
													return

								__magic_name__				,     __magic_name__				:						List[str]     				=				self.model_tester.prepare_config_and_inputs_for_common()
								__magic_name__				:						Any     				=				True

								for model_class in self.all_model_classes:
													if model_class in [*get_values(lowerCamelCase_	)]:
																		continue

													__magic_name__				:						Dict     				=				model_class(lowerCamelCase_	)
													model.to(lowerCamelCase_	)
													model.train()
													__magic_name__				:						Tuple     				=				self._prepare_for_class(lowerCamelCase_							,    lowerCamelCase_							,    return_labels=lowerCamelCase_	)
													__magic_name__				:						Dict     				=				model(**lowerCamelCase_	).loss
													loss.backward()

			def 				UpperCAmelCase__							(			self      : str	)    -> List[Any]:
								__magic_name__				,     __magic_name__				:						Optional[int]     				=				self.model_tester.prepare_config_and_inputs_for_common()
								if not self.model_tester.is_training:
													return

								__magic_name__				:						Dict     				=				False
								__magic_name__				:						Dict     				=				True

								for model_class in self.all_model_classes:
													if model_class in [*get_values(lowerCamelCase_	)] or not model_class.supports_gradient_checkpointing:
																		continue
													# TODO: remove the following 3 lines once we have a MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING
													# this can then be incorporated into _prepare_for_class in test_modeling_common.py
													elif model_class.__name__ == "Data2VecVisionForSemanticSegmentation":
																		__magic_name__				,     __magic_name__				,     __magic_name__				,     __magic_name__				:						Tuple     				=				inputs_dict['''pixel_values'''].shape
																		__magic_name__				:						str     				=				torch.zeros(
																		    [self.model_tester.batch_size, height, width]							,    device=lowerCamelCase_	).long()
													__magic_name__				:						Any     				=				model_class(lowerCamelCase_	)
													model.gradient_checkpointing_enable()
													model.to(lowerCamelCase_	)
													model.train()
													__magic_name__				:						Optional[Any]     				=				self._prepare_for_class(lowerCamelCase_							,    lowerCamelCase_							,    return_labels=lowerCamelCase_	)
													__magic_name__				:						Dict     				=				model(**lowerCamelCase_	).loss
													loss.backward()

			def 				UpperCAmelCase__							(			self      : int	)    -> Any:
								__magic_name__				,     __magic_name__				:						Any     				=				self.model_tester.prepare_config_and_inputs_for_common()

								__magic_name__				:						Any     				=				_config_zero_init(lowerCamelCase_	)
								for model_class in self.all_model_classes:
													__magic_name__				:						int     				=				model_class(config=lowerCamelCase_	)
													for name, param in model.named_parameters():
																		# we skip lambda parameters as these require special initial values
																		# determined by config.layer_scale_init_value
																		if "lambda" in name:
																							continue
																		if param.requires_grad:
																							self.assertIn(
																							    ((param.data.mean() * 1E9).round() / 1E9).item()							,    [0.0, 1.0]							,    msg=F'''Parameter {name} of model {model_class} seems not properly initialized'''							,    )

			def 				UpperCAmelCase__							(			self      : List[Any]							,    lowerCamelCase_      : Union[str, Any]							,    lowerCamelCase_      : List[str]							,    lowerCamelCase_      : int							,    lowerCamelCase_      : Optional[int]=2E-4							,    lowerCamelCase_      : List[Any]="outputs"							,    lowerCamelCase_      : Union[str, Any]=None	)    -> List[str]:
								# We override with a slightly higher tol value, as semseg models tend to diverge a bit more
								super().check_pt_tf_outputs(lowerCamelCase_							,    lowerCamelCase_							,    lowerCamelCase_							,    lowerCamelCase_							,    lowerCamelCase_							,    lowerCamelCase_	)

			def 				UpperCAmelCase__							(			self      : Dict	)    -> int:
								__magic_name__				:						Optional[int]     				=				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_image_classification(*lowerCamelCase_	)


			@slow
			def 				UpperCAmelCase__							(			self      : Optional[Any]	)    -> int:
								for model_name in DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
													__magic_name__				:						int     				=				DataaVecVisionModel.from_pretrained(lowerCamelCase_	)
													self.assertIsNotNone(lowerCamelCase_	)







def 		lowercase__ (		):





					'''simple docstring'''






					__magic_name__				:						Tuple     				=				Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''					)
					return image


@require_torch
@require_vision
class  lowerCamelCase     (		unittest.TestCase    ):






			'''simple docstring'''





			@cached_property
			def 				UpperCAmelCase__							(			self      : Union[str, Any]	)    -> Optional[int]:
								return (
								    BeitImageProcessor.from_pretrained('''facebook/data2vec-vision-base-ft1k'''	) if is_vision_available() else None
								)


			@slow
			def 				UpperCAmelCase__							(			self      : List[str]	)    -> Union[str, Any]:
								__magic_name__				:						str     				=				DataaVecVisionForImageClassification.from_pretrained('''facebook/data2vec-vision-base-ft1k'''	).to(
								    lowerCamelCase_	)

								__magic_name__				:						str     				=				self.default_image_processor
								__magic_name__				:						Tuple     				=				prepare_img()
								__magic_name__				:						Tuple     				=				image_processor(images=lowerCamelCase_							,    return_tensors='''pt'''	).to(lowerCamelCase_	)

								# forward pass
								with torch.no_grad():
													__magic_name__				:						Optional[int]     				=				model(**lowerCamelCase_	)
								__magic_name__				:						List[str]     				=				outputs.logits

								# verify the logits
								__magic_name__				:						Optional[Any]     				=				torch.Size((1, 1000)	)
								self.assertEqual(logits.shape							,    lowerCamelCase_	)

								__magic_name__				:						Optional[int]     				=				torch.tensor([0.3_2_7_7, -0.1_3_9_5, 0.0_9_1_1]	).to(lowerCamelCase_	)

								self.assertTrue(torch.allclose(logits[0, :3]							,    lowerCamelCase_							,    atol=1E-4	)	)

								__magic_name__				:						str     				=				[model.config.labelaid[i] for i in ['''remote control, remote''', '''tabby, tabby cat''']]
								self.assertEqual(logits[0].topk(2	).indices.cpu().tolist()							,    lowerCamelCase_	)









from typing import TYPE_CHECKING

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


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

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowerCamelCase :    Any      						=      [
	    '''Constraint''',
	    '''ConstraintListState''',
	    '''DisjunctiveConstraint''',
	    '''PhrasalConstraint''',
	]
	__lowerCamelCase :    int      						=      [
	    '''BeamHypotheses''',
	    '''BeamScorer''',
	    '''BeamSearchScorer''',
	    '''ConstrainedBeamSearchScorer''',
	]
	__lowerCamelCase :    Union[str, Any]      						=      [
	    '''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 :    Union[str, Any]      						=      [
	    '''MaxNewTokensCriteria''',
	    '''MaxLengthCriteria''',
	    '''MaxTimeCriteria''',
	    '''StoppingCriteria''',
	    '''StoppingCriteriaList''',
	    '''validate_stopping_criteria''',
	]
	__lowerCamelCase :    Union[str, Any]      						=      [
	    '''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 :    Tuple      						=      [
	    '''TFForcedBOSTokenLogitsProcessor''',
	    '''TFForcedEOSTokenLogitsProcessor''',
	    '''TFLogitsProcessor''',
	    '''TFLogitsProcessorList''',
	    '''TFLogitsWarper''',
	    '''TFMinLengthLogitsProcessor''',
	    '''TFNoBadWordsLogitsProcessor''',
	    '''TFNoRepeatNGramLogitsProcessor''',
	    '''TFRepetitionPenaltyLogitsProcessor''',
	    '''TFTemperatureLogitsWarper''',
	    '''TFTopKLogitsWarper''',
	    '''TFTopPLogitsWarper''',
	    '''TFForceTokensLogitsProcessor''',
	    '''TFSuppressTokensAtBeginLogitsProcessor''',
	    '''TFSuppressTokensLogitsProcessor''',
	]
	__lowerCamelCase :    Any      						=      [
	    '''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 :    Optional[int]      						=      [
	    '''FlaxForcedBOSTokenLogitsProcessor''',
	    '''FlaxForcedEOSTokenLogitsProcessor''',
	    '''FlaxLogitsProcessor''',
	    '''FlaxLogitsProcessorList''',
	    '''FlaxLogitsWarper''',
	    '''FlaxMinLengthLogitsProcessor''',
	    '''FlaxTemperatureLogitsWarper''',
	    '''FlaxTopKLogitsWarper''',
	    '''FlaxTopPLogitsWarper''',
	]
	__lowerCamelCase :    Union[str, Any]      						=      [
	    '''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 :    int      						=      _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)



