






from __future__ import annotations

import unittest

from transformers import MobileBertConfig, is_tf_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
	import tensorflow as tf

	from transformers import (
	    TF_MODEL_FOR_PRETRAINING_MAPPING,
	    TFMobileBertForMaskedLM,
	    TFMobileBertForMultipleChoice,
	    TFMobileBertForNextSentencePrediction,
	    TFMobileBertForPreTraining,
	    TFMobileBertForQuestionAnswering,
	    TFMobileBertForSequenceClassification,
	    TFMobileBertForTokenClassification,
	    TFMobileBertModel,
	)

@require_tf
class     _SCREAMING_SNAKE_CASE       (			_a		,   _a		,   unittest.TestCase      ):
	snake_case__							:     Optional[Any]     	=  (
	    (
	        TFMobileBertModel,
	        TFMobileBertForMaskedLM,
	        TFMobileBertForNextSentencePrediction,
	        TFMobileBertForPreTraining,
	        TFMobileBertForQuestionAnswering,
	        TFMobileBertForSequenceClassification,
	        TFMobileBertForTokenClassification,
	        TFMobileBertForMultipleChoice,
	    )
	    if is_tf_available()
	    else ()
	)
	snake_case__							:     Any     	=  (
	    {
	        """feature-extraction""": TFMobileBertModel,
	        """fill-mask""": TFMobileBertForMaskedLM,
	        """question-answering""": TFMobileBertForQuestionAnswering,
	        """text-classification""": TFMobileBertForSequenceClassification,
	        """token-classification""": TFMobileBertForTokenClassification,
	        """zero-shot""": TFMobileBertForSequenceClassification,
	    }
	    if is_tf_available()
	    else {}
	)
	snake_case__							:     Union[str, Any]     	=  False
	snake_case__							:     Dict     	=  False





	def 						_A (		self				:					List[Any] ,  __lowerCamelCase				:					List[Any] ,  __lowerCamelCase				:					int ,  __lowerCamelCase				:					int=False	):
		UpperCamelCase     :Dict          =	super()._prepare_for_class(__lowerCamelCase ,  __lowerCamelCase ,  return_labels=__lowerCamelCase	)

		if return_labels:
			if model_class in get_values(__lowerCamelCase	):
				UpperCamelCase     :List[Any]          =	tf.zeros(self.model_tester.batch_size ,  dtype=tf.intaa	)

		return inputs_dict

	class     _SCREAMING_SNAKE_CASE       (			_a      ):





		def __init__(		self				:					int ,  __lowerCamelCase				:					Optional[int] ,  __lowerCamelCase				:					str=13 ,  __lowerCamelCase				:					List[Any]=7 ,  __lowerCamelCase				:					str=True ,  __lowerCamelCase				:					List[Any]=True ,  __lowerCamelCase				:					Dict=True ,  __lowerCamelCase				:					Optional[Any]=True ,  __lowerCamelCase				:					Union[str, Any]=99 ,  __lowerCamelCase				:					Union[str, Any]=32 ,  __lowerCamelCase				:					Optional[int]=32 ,  __lowerCamelCase				:					Optional[int]=2 ,  __lowerCamelCase				:					List[Any]=4 ,  __lowerCamelCase				:					Tuple=37 ,  __lowerCamelCase				:					Any="gelu" ,  __lowerCamelCase				:					Any=0.1 ,  __lowerCamelCase				:					List[Any]=0.1 ,  __lowerCamelCase				:					Tuple=512 ,  __lowerCamelCase				:					Dict=16 ,  __lowerCamelCase				:					Optional[Any]=2 ,  __lowerCamelCase				:					Any=0.02 ,  __lowerCamelCase				:					Optional[int]=3 ,  __lowerCamelCase				:					Tuple=4 ,  __lowerCamelCase				:					List[str]=None ,  ):
			UpperCamelCase     :Optional[int]          =	parent
			UpperCamelCase     :str          =	batch_size
			UpperCamelCase     :Optional[int]          =	seq_length
			UpperCamelCase     :Optional[Any]          =	is_training
			UpperCamelCase     :List[str]          =	use_input_mask
			UpperCamelCase     :Union[str, Any]          =	use_token_type_ids
			UpperCamelCase     :Tuple          =	use_labels
			UpperCamelCase     :Union[str, Any]          =	vocab_size
			UpperCamelCase     :Optional[Any]          =	hidden_size
			UpperCamelCase     :Any          =	num_hidden_layers
			UpperCamelCase     :List[str]          =	num_attention_heads
			UpperCamelCase     :List[str]          =	intermediate_size
			UpperCamelCase     :int          =	hidden_act
			UpperCamelCase     :Any          =	hidden_dropout_prob
			UpperCamelCase     :int          =	attention_probs_dropout_prob
			UpperCamelCase     :str          =	max_position_embeddings
			UpperCamelCase     :str          =	type_vocab_size
			UpperCamelCase     :Union[str, Any]          =	type_sequence_label_size
			UpperCamelCase     :Tuple          =	initializer_range
			UpperCamelCase     :List[Any]          =	num_labels
			UpperCamelCase     :Union[str, Any]          =	num_choices
			UpperCamelCase     :List[Any]          =	scope
			UpperCamelCase     :Any          =	embedding_size





		def 						_A (		self				:					Dict	):
			UpperCamelCase     :Dict          =	ids_tensor([self.batch_size, self.seq_length] ,  self.vocab_size	)

			UpperCamelCase     :List[Any]          =	None
			if self.use_input_mask:
				UpperCamelCase     :Optional[int]          =	random_attention_mask([self.batch_size, self.seq_length]	)

			UpperCamelCase     :Tuple          =	None
			if self.use_token_type_ids:
				UpperCamelCase     :Optional[int]          =	ids_tensor([self.batch_size, self.seq_length] ,  self.type_vocab_size	)

			UpperCamelCase     :Optional[int]          =	None
			UpperCamelCase     :Dict          =	None
			UpperCamelCase     :Tuple          =	None
			if self.use_labels:
				UpperCamelCase     :Any          =	ids_tensor([self.batch_size] ,  self.type_sequence_label_size	)
				UpperCamelCase     :Optional[Any]          =	ids_tensor([self.batch_size, self.seq_length] ,  self.num_labels	)
				UpperCamelCase     :Tuple          =	ids_tensor([self.batch_size] ,  self.num_choices	)

			UpperCamelCase     :Union[str, Any]          =	MobileBertConfig(
			    vocab_size=self.vocab_size ,  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 ,  max_position_embeddings=self.max_position_embeddings ,  type_vocab_size=self.type_vocab_size ,  initializer_range=self.initializer_range ,  embedding_size=self.embedding_size ,  )

			return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels





		def 						_A (		self				:					List[str] ,  __lowerCamelCase				:					Union[str, Any] ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					Optional[int] ,  __lowerCamelCase				:					List[Any] ,  __lowerCamelCase				:					List[Any] ,  __lowerCamelCase				:					Dict	):
			UpperCamelCase     :Dict          =	TFMobileBertModel(config=__lowerCamelCase	)
			UpperCamelCase     :Optional[int]          =	{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
			UpperCamelCase     :str          =	model(__lowerCamelCase	)

			UpperCamelCase     :Any          =	[input_ids, input_mask]
			UpperCamelCase     :Dict          =	model(__lowerCamelCase	)

			UpperCamelCase     :int          =	model(__lowerCamelCase	)

			self.parent.assertEqual(
			    result.last_hidden_state.shape ,  (self.batch_size, self.seq_length, self.hidden_size)	)
			self.parent.assertEqual(result.pooler_output.shape ,  (self.batch_size, self.hidden_size)	)





		def 						_A (		self				:					Any ,  __lowerCamelCase				:					Optional[int] ,  __lowerCamelCase				:					Dict ,  __lowerCamelCase				:					Dict ,  __lowerCamelCase				:					Optional[int] ,  __lowerCamelCase				:					Optional[int] ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					List[Any]	):
			UpperCamelCase     :Optional[Any]          =	TFMobileBertForMaskedLM(config=__lowerCamelCase	)
			UpperCamelCase     :int          =	{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
			UpperCamelCase     :Dict          =	model(__lowerCamelCase	)
			self.parent.assertEqual(result.logits.shape ,  (self.batch_size, self.seq_length, self.vocab_size)	)





		def 						_A (		self				:					int ,  __lowerCamelCase				:					Tuple ,  __lowerCamelCase				:					Tuple ,  __lowerCamelCase				:					Union[str, Any] ,  __lowerCamelCase				:					str ,  __lowerCamelCase				:					str ,  __lowerCamelCase				:					List[str] ,  __lowerCamelCase				:					int	):
			UpperCamelCase     :str          =	TFMobileBertForNextSentencePrediction(config=__lowerCamelCase	)
			UpperCamelCase     :Optional[int]          =	{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
			UpperCamelCase     :int          =	model(__lowerCamelCase	)
			self.parent.assertEqual(result.logits.shape ,  (self.batch_size, 2)	)





		def 						_A (		self				:					Optional[Any] ,  __lowerCamelCase				:					str ,  __lowerCamelCase				:					str ,  __lowerCamelCase				:					Dict ,  __lowerCamelCase				:					int ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					Optional[int] ,  __lowerCamelCase				:					Union[str, Any]	):
			UpperCamelCase     :Optional[int]          =	TFMobileBertForPreTraining(config=__lowerCamelCase	)
			UpperCamelCase     :Any          =	{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
			UpperCamelCase     :Any          =	model(__lowerCamelCase	)
			self.parent.assertEqual(
			    result.prediction_logits.shape ,  (self.batch_size, self.seq_length, self.vocab_size)	)
			self.parent.assertEqual(result.seq_relationship_logits.shape ,  (self.batch_size, 2)	)





		def 						_A (		self				:					Optional[int] ,  __lowerCamelCase				:					Union[str, Any] ,  __lowerCamelCase				:					Any ,  __lowerCamelCase				:					List[str] ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					List[str] ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					Any	):
			UpperCamelCase     :int          =	self.num_labels
			UpperCamelCase     :Union[str, Any]          =	TFMobileBertForSequenceClassification(config=__lowerCamelCase	)
			UpperCamelCase     :Union[str, Any]          =	{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
			UpperCamelCase     :List[str]          =	model(__lowerCamelCase	)
			self.parent.assertEqual(result.logits.shape ,  (self.batch_size, self.num_labels)	)





		def 						_A (		self				:					List[str] ,  __lowerCamelCase				:					Dict ,  __lowerCamelCase				:					Union[str, Any] ,  __lowerCamelCase				:					List[str] ,  __lowerCamelCase				:					Optional[int] ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					int ,  __lowerCamelCase				:					int	):
			UpperCamelCase     :str          =	self.num_choices
			UpperCamelCase     :List[str]          =	TFMobileBertForMultipleChoice(config=__lowerCamelCase	)
			UpperCamelCase     :Dict          =	tf.tile(tf.expand_dims(__lowerCamelCase ,  1	) ,  (1, self.num_choices, 1)	)
			UpperCamelCase     :Tuple          =	tf.tile(tf.expand_dims(__lowerCamelCase ,  1	) ,  (1, self.num_choices, 1)	)
			UpperCamelCase     :Optional[Any]          =	tf.tile(tf.expand_dims(__lowerCamelCase ,  1	) ,  (1, self.num_choices, 1)	)
			UpperCamelCase     :int          =	{
			    """input_ids""": multiple_choice_inputs_ids,
			    """attention_mask""": multiple_choice_input_mask,
			    """token_type_ids""": multiple_choice_token_type_ids,
			}
			UpperCamelCase     :List[str]          =	model(__lowerCamelCase	)
			self.parent.assertEqual(result.logits.shape ,  (self.batch_size, self.num_choices)	)





		def 						_A (		self				:					int ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					str ,  __lowerCamelCase				:					Dict ,  __lowerCamelCase				:					int ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					Dict ,  __lowerCamelCase				:					Dict	):
			UpperCamelCase     :str          =	self.num_labels
			UpperCamelCase     :int          =	TFMobileBertForTokenClassification(config=__lowerCamelCase	)
			UpperCamelCase     :Dict          =	{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
			UpperCamelCase     :Tuple          =	model(__lowerCamelCase	)
			self.parent.assertEqual(result.logits.shape ,  (self.batch_size, self.seq_length, self.num_labels)	)





		def 						_A (		self				:					int ,  __lowerCamelCase				:					List[Any] ,  __lowerCamelCase				:					str ,  __lowerCamelCase				:					Dict ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					Optional[int] ,  __lowerCamelCase				:					Optional[int] ,  __lowerCamelCase				:					Any	):
			UpperCamelCase     :Union[str, Any]          =	TFMobileBertForQuestionAnswering(config=__lowerCamelCase	)
			UpperCamelCase     :Tuple          =	{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
			UpperCamelCase     :Tuple          =	model(__lowerCamelCase	)
			self.parent.assertEqual(result.start_logits.shape ,  (self.batch_size, self.seq_length)	)
			self.parent.assertEqual(result.end_logits.shape ,  (self.batch_size, self.seq_length)	)





		def 						_A (		self				:					str	):
			UpperCamelCase     :Tuple          =	self.prepare_config_and_inputs()
			(
			    (
			    UpperCamelCase
			)     ,      (
			    UpperCamelCase
			)     ,      (
			    UpperCamelCase
			)     ,      (
			    UpperCamelCase
			)     ,      (
			    UpperCamelCase
			)     ,      (
			    UpperCamelCase
			)     ,      (
			    UpperCamelCase
			)     ,      
			)     :Dict          =	config_and_inputs
			UpperCamelCase     :Optional[Any]          =	{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
			return config, inputs_dict





	def 						_A (		self				:					Tuple	):
		UpperCamelCase     :int          =	TFMobileBertModelTest.TFMobileBertModelTester(self	)
		UpperCamelCase     :Dict          =	ConfigTester(self ,  config_class=__lowerCamelCase ,  hidden_size=37	)





	def 						_A (		self				:					int	):
		self.config_tester.run_common_tests()





	def 						_A (		self				:					List[Any]	):
		UpperCamelCase     :Dict          =	self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_mobilebert_model(*__lowerCamelCase	)





	def 						_A (		self				:					Optional[Any]	):
		UpperCamelCase     :Tuple          =	self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_mobilebert_for_masked_lm(*__lowerCamelCase	)





	def 						_A (		self				:					Union[str, Any]	):
		UpperCamelCase     :int          =	self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_mobilebert_for_multiple_choice(*__lowerCamelCase	)





	def 						_A (		self				:					str	):
		UpperCamelCase     :Union[str, Any]          =	self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_mobilebert_for_next_sequence_prediction(*__lowerCamelCase	)





	def 						_A (		self				:					Dict	):
		UpperCamelCase     :str          =	self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_mobilebert_for_pretraining(*__lowerCamelCase	)





	def 						_A (		self				:					Any	):
		UpperCamelCase     :Dict          =	self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_mobilebert_for_question_answering(*__lowerCamelCase	)





	def 						_A (		self				:					Tuple	):
		UpperCamelCase     :Union[str, Any]          =	self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_mobilebert_for_sequence_classification(*__lowerCamelCase	)





	def 						_A (		self				:					Any	):
		UpperCamelCase     :str          =	self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_mobilebert_for_token_classification(*__lowerCamelCase	)





	@slow
	def 						_A (		self				:					int	):
		# for model_name in TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
		for model_name in ["google/mobilebert-uncased"]:
			UpperCamelCase     :Optional[int]          =	TFMobileBertModel.from_pretrained(__lowerCamelCase	)
			self.assertIsNotNone(__lowerCamelCase	)

@require_tf
class     _SCREAMING_SNAKE_CASE       (			unittest.TestCase      ):





	@slow
	def 						_A (		self				:					Tuple	):
		UpperCamelCase     :List[Any]          =	TFMobileBertForPreTraining.from_pretrained("""google/mobilebert-uncased"""	)
		UpperCamelCase     :str          =	tf.constant([[0, 1, 2, 3, 4, 5]]	)
		UpperCamelCase     :Dict          =	model(__lowerCamelCase	)[0]

		UpperCamelCase     :str          =	[1, 6, 30_522]
		self.assertEqual(output.shape ,  __lowerCamelCase	)

		UpperCamelCase     :int          =	tf.constant(
		    [
		        [
		            [-4.5919547, -9.248295, -9.645256],
		            [-6.7306175, -6.440284, -6.6052837],
		            [-7.2743506, -6.7847915, -6.024673],
		        ]
		    ]	)
		tf.debugging.assert_near(output[:, :3, :3] ,  __lowerCamelCase ,  atol=1E-4	)








from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import logging


if TYPE_CHECKING:
	from ...processing_utils import ProcessorMixin
	from ...utils import TensorType


UpperCAmelCase_ :						Dict      =      logging.get_logger(__name__)

UpperCAmelCase_ :						str      =      {
    '''microsoft/layoutlmv3-base''': '''https://huggingface.co/microsoft/layoutlmv3-base/resolve/main/config.json''',
}

class     _SCREAMING_SNAKE_CASE       (			_a      ):
	snake_case__							:     Optional[int]     	=  """layoutlmv3"""





	def __init__(		self				:					List[Any] ,  __lowerCamelCase				:					Optional[Any]=50_265 ,  __lowerCamelCase				:					Dict=768 ,  __lowerCamelCase				:					Any=12 ,  __lowerCamelCase				:					int=12 ,  __lowerCamelCase				:					str=3_072 ,  __lowerCamelCase				:					List[Any]="gelu" ,  __lowerCamelCase				:					List[str]=0.1 ,  __lowerCamelCase				:					Optional[int]=0.1 ,  __lowerCamelCase				:					Optional[Any]=512 ,  __lowerCamelCase				:					Optional[int]=2 ,  __lowerCamelCase				:					Union[str, Any]=0.02 ,  __lowerCamelCase				:					Union[str, Any]=1E-5 ,  __lowerCamelCase				:					Any=1 ,  __lowerCamelCase				:					Optional[int]=0 ,  __lowerCamelCase				:					List[Any]=2 ,  __lowerCamelCase				:					Dict=1_024 ,  __lowerCamelCase				:					List[Any]=128 ,  __lowerCamelCase				:					str=128 ,  __lowerCamelCase				:					Optional[Any]=True ,  __lowerCamelCase				:					str=32 ,  __lowerCamelCase				:					List[Any]=128 ,  __lowerCamelCase				:					str=64 ,  __lowerCamelCase				:					List[str]=256 ,  __lowerCamelCase				:					Dict=True ,  __lowerCamelCase				:					List[Any]=True ,  __lowerCamelCase				:					Tuple=True ,  __lowerCamelCase				:					Tuple=224 ,  __lowerCamelCase				:					Tuple=3 ,  __lowerCamelCase				:					Dict=16 ,  __lowerCamelCase				:					Union[str, Any]=None ,  **__lowerCamelCase				:					Optional[Any] ,  ):
		super().__init__(
		    vocab_size=__lowerCamelCase ,  hidden_size=__lowerCamelCase ,  num_hidden_layers=__lowerCamelCase ,  num_attention_heads=__lowerCamelCase ,  intermediate_size=__lowerCamelCase ,  hidden_act=__lowerCamelCase ,  hidden_dropout_prob=__lowerCamelCase ,  attention_probs_dropout_prob=__lowerCamelCase ,  max_position_embeddings=__lowerCamelCase ,  type_vocab_size=__lowerCamelCase ,  initializer_range=__lowerCamelCase ,  layer_norm_eps=__lowerCamelCase ,  pad_token_id=__lowerCamelCase ,  bos_token_id=__lowerCamelCase ,  eos_token_id=__lowerCamelCase ,  **__lowerCamelCase ,  )
		UpperCamelCase     :int          =	max_ad_position_embeddings
		UpperCamelCase     :Tuple          =	coordinate_size
		UpperCamelCase     :List[Any]          =	shape_size
		UpperCamelCase     :Union[str, Any]          =	has_relative_attention_bias
		UpperCamelCase     :Any          =	rel_pos_bins
		UpperCamelCase     :Optional[Any]          =	max_rel_pos
		UpperCamelCase     :str          =	has_spatial_attention_bias
		UpperCamelCase     :Tuple          =	rel_ad_pos_bins
		UpperCamelCase     :Optional[int]          =	max_rel_ad_pos
		UpperCamelCase     :Tuple          =	text_embed
		UpperCamelCase     :str          =	visual_embed
		UpperCamelCase     :Optional[Any]          =	input_size
		UpperCamelCase     :str          =	num_channels
		UpperCamelCase     :List[Any]          =	patch_size
		UpperCamelCase     :Optional[Any]          =	classifier_dropout

class     _SCREAMING_SNAKE_CASE       (			_a      ):
	snake_case__							:     int     	=  version.parse("""1.12"""      )





	@property
	def 						_A (		self				:					Optional[int]	):
		# The order of inputs is different for question answering and sequence classification
		if self.task in ["question-answering", "sequence-classification"]:
			return OrderedDict(
			    [
			        ("""input_ids""", {0: """batch""", 1: """sequence"""}),
			        ("""attention_mask""", {0: """batch""", 1: """sequence"""}),
			        ("""bbox""", {0: """batch""", 1: """sequence"""}),
			        ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
			    ]	)
		else:
			return OrderedDict(
			    [
			        ("""input_ids""", {0: """batch""", 1: """sequence"""}),
			        ("""bbox""", {0: """batch""", 1: """sequence"""}),
			        ("""attention_mask""", {0: """batch""", 1: """sequence"""}),
			        ("""pixel_values""", {0: """batch""", 1: """num_channels"""}),
			    ]	)





	@property
	def 						_A (		self				:					str	):
		return 1E-5





	@property
	def 						_A (		self				:					Dict	):
		return 12





	def 						_A (		self				:					Dict ,  __lowerCamelCase				:					"ProcessorMixin" ,  __lowerCamelCase				:					int = -1 ,  __lowerCamelCase				:					int = -1 ,  __lowerCamelCase				:					bool = False ,  __lowerCamelCase				:					Optional["TensorType"] = None ,  __lowerCamelCase				:					int = 3 ,  __lowerCamelCase				:					int = 40 ,  __lowerCamelCase				:					int = 40 ,  ):
		setattr(processor.image_processor ,  """apply_ocr""" ,  __lowerCamelCase	)

		# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
		UpperCamelCase     :Optional[Any]          =	compute_effective_axis_dimension(
		    __lowerCamelCase ,  fixed_dimension=OnnxConfig.default_fixed_batch ,  num_token_to_add=0	)
		# If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
		UpperCamelCase     :Optional[int]          =	processor.tokenizer.num_special_tokens_to_add(__lowerCamelCase	)
		UpperCamelCase     :int          =	compute_effective_axis_dimension(
		    __lowerCamelCase ,  fixed_dimension=OnnxConfig.default_fixed_sequence ,  num_token_to_add=__lowerCamelCase	)
		# Generate dummy inputs according to compute batch and sequence
		UpperCamelCase     :Any          =	[[""" """.join([processor.tokenizer.unk_token]	) * seq_length]] * batch_size

		# Generate dummy bounding boxes
		UpperCamelCase     :Optional[Any]          =	[[[48, 84, 73, 128]]] * batch_size

		# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
		# batch_size = compute_effective_axis_dimension(batch_size, fixed_dimension=OnnxConfig.default_fixed_batch)
		UpperCamelCase     :List[str]          =	self._generate_dummy_images(__lowerCamelCase ,  __lowerCamelCase ,  __lowerCamelCase ,  __lowerCamelCase	)

		UpperCamelCase     :Any          =	dict(
		    processor(
		        __lowerCamelCase ,  text=__lowerCamelCase ,  boxes=__lowerCamelCase ,  return_tensors=__lowerCamelCase ,  )	)

		return inputs
