
import unittest

from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer
from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow
from transformers.utils import cached_property

from ...test_tokenization_common import TokenizerTesterMixin


__a         =   get_tests_dir('fixtures/test_sentencepiece.model')
@require_sentencepiece
class 					lowercase__(							UpperCAmelCase					,		unittest.TestCase				):



	"""simple docstring"""




	a     :Optional[int]       	=      XLMProphetNetTokenizer
	a     :Any       	=      False
	a     :Optional[int]       	=      True
	def 		_lowercase    (			self    :     Optional[int]			)			->	List[str]:
					super().setUp()

					# We have a SentencePiece fixture for testing
					lowercase_	    =   XLMProphetNetTokenizer(SCREAMING_SNAKE_CASE_			,				keep_accents=SCREAMING_SNAKE_CASE_			)
					tokenizer.save_pretrained(self.tmpdirname			)
	def 		_lowercase    (			self    :     Any			)			->	Optional[Any]:
					lowercase_	    =   '''[PAD]'''
					lowercase_	    =   0

					self.assertEqual(self.get_tokenizer()._convert_token_to_id(SCREAMING_SNAKE_CASE_			)			,				SCREAMING_SNAKE_CASE_			)
					self.assertEqual(self.get_tokenizer()._convert_id_to_token(SCREAMING_SNAKE_CASE_			)			,				SCREAMING_SNAKE_CASE_			)
	def 		_lowercase    (			self    :     Optional[Any]			)			->	int:
					lowercase_	    =   list(self.get_tokenizer().get_vocab().keys()			)

					self.assertEqual(vocab_keys[0]			,				'''[PAD]'''			)
					self.assertEqual(vocab_keys[1]			,				'''[CLS]'''			)
					self.assertEqual(vocab_keys[-1]			,				'''j'''			)
					self.assertEqual(len(SCREAMING_SNAKE_CASE_			)			,				1_0_1_2			)
	def 		_lowercase    (			self    :     int			)			->	int:
					self.assertEqual(self.get_tokenizer().vocab_size			,				1_0_1_2			)
	def 		_lowercase    (			self    :     Union[str, Any]			)			->	Union[str, Any]:
					lowercase_	    =   XLMProphetNetTokenizer(SCREAMING_SNAKE_CASE_			,				keep_accents=SCREAMING_SNAKE_CASE_			)

					lowercase_	    =   tokenizer.tokenize('''This is a test'''			)
					self.assertListEqual(SCREAMING_SNAKE_CASE_			,				['''▁This''', '''▁is''', '''▁a''', '''▁t''', '''est''']			)

					self.assertListEqual(
					    tokenizer.convert_tokens_to_ids(SCREAMING_SNAKE_CASE_			)			,				[value + tokenizer.fairseq_offset for value in [2_8_5, 4_6, 1_0, 1_7_0, 3_8_2]]			,				)

					lowercase_	    =   tokenizer.tokenize('''I was born in 92000, and this is falsé.'''			)
					self.assertListEqual(
					    SCREAMING_SNAKE_CASE_			,				[
					        SPIECE_UNDERLINE + '''I''',
					        SPIECE_UNDERLINE + '''was''',
					        SPIECE_UNDERLINE + '''b''',
					        '''or''',
					        '''n''',
					        SPIECE_UNDERLINE + '''in''',
					        SPIECE_UNDERLINE + '''''',
					        '''9''',
					        '''2''',
					        '''0''',
					        '''0''',
					        '''0''',
					        ''',''',
					        SPIECE_UNDERLINE + '''and''',
					        SPIECE_UNDERLINE + '''this''',
					        SPIECE_UNDERLINE + '''is''',
					        SPIECE_UNDERLINE + '''f''',
					        '''al''',
					        '''s''',
					        '''é''',
					        '''.''',
					    ]			,				)
					lowercase_	    =   tokenizer.convert_tokens_to_ids(SCREAMING_SNAKE_CASE_			)
					self.assertListEqual(
					    SCREAMING_SNAKE_CASE_			,				[
					        value + tokenizer.fairseq_offset
					        for value in [8, 2_1, 8_4, 5_5, 2_4, 1_9, 7, -9, 6_0_2, 3_4_7, 3_4_7, 3_4_7, 3, 1_2, 6_6, 4_6, 7_2, 8_0, 6, -9, 4]
					    ]			,				)

					lowercase_	    =   tokenizer.convert_ids_to_tokens(SCREAMING_SNAKE_CASE_			)
					self.assertListEqual(
					    SCREAMING_SNAKE_CASE_			,				[
					        SPIECE_UNDERLINE + '''I''',
					        SPIECE_UNDERLINE + '''was''',
					        SPIECE_UNDERLINE + '''b''',
					        '''or''',
					        '''n''',
					        SPIECE_UNDERLINE + '''in''',
					        SPIECE_UNDERLINE + '''''',
					        '''[UNK]''',
					        '''2''',
					        '''0''',
					        '''0''',
					        '''0''',
					        ''',''',
					        SPIECE_UNDERLINE + '''and''',
					        SPIECE_UNDERLINE + '''this''',
					        SPIECE_UNDERLINE + '''is''',
					        SPIECE_UNDERLINE + '''f''',
					        '''al''',
					        '''s''',
					        '''[UNK]''',
					        '''.''',
					    ]			,				)
	@cached_property
	def 		_lowercase    (			self    :     Tuple			)			->	List[Any]:
					return XLMProphetNetTokenizer.from_pretrained('''microsoft/xprophetnet-large-wiki100-cased'''			)
	@slow
	def 		_lowercase    (			self    :     Optional[int]			)			->	Union[str, Any]:
					lowercase_	    =   '''Hello World!'''
					lowercase_	    =   [3_5_3_8_9, 6_6_7_2, 4_9, 2]
					self.assertListEqual(SCREAMING_SNAKE_CASE_			,				self.big_tokenizer.encode(SCREAMING_SNAKE_CASE_			)			)




	@slow
	def 		_lowercase    (			self    :     Any			)			->	List[Any]:
					# fmt: off
					lowercase_	    =   {'''input_ids''': [[1_1_0_7_3, 8_2_7_8_3, 1_8, 2_6, 8_2_7_8_3, 5_4_9, 5_1_5_4_0, 2_4_8, 1_7_2_0_9, 1_3_0_1, 2_1_7, 2_0, 2_1_5_1_8_6, 1_3_2_5, 1_4_7, 1_7_2_0_9, 1_3_0_1, 2_1_7, 2_0, 5_6_3_7_0, 5_3, 1_2_2_0_2_0, 2_0, 1_6_4_7_7, 2_7, 8_7_3_5_5, 4_5_4_8, 2_0, 4_7_2_8, 7_8_3_9_2, 1_7, 1_5_9_9_6_9, 1_8, 2_6, 2_4_4_9_1, 6_2_9, 1_5, 5_3_8, 2_2_7_0_4, 5_4_3_9, 1_5, 2_7_8_8, 2_4_4_9_1, 9_8_8_5, 1_5, 4_3_5_3_4, 6_0_5, 1_5, 8_1_4, 1_8_4_0_3, 3_3_2_0_0, 2_9, 1_5, 4_3_5_3_4, 2_4_4_5_8, 1_2_4_1_0, 1_1_1, 2_4_9_6_6, 8_3_6_6_9, 9_6_3_7, 1_4_4_0_6_8, 2_6, 8_5_0, 2_2_3_4_6, 2_7, 1_4_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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]}  # noqa: E501
					# fmt: on

					self.tokenizer_integration_test_util(
					    expected_encoding=SCREAMING_SNAKE_CASE_			,				model_name='''microsoft/xprophetnet-large-wiki100-cased'''			,				revision='''1acad1643ddd54a44df6a1b797ada8373685d90e'''			,				)







import unittest

from transformers import (
    MODEL_FOR_OBJECT_DETECTION_MAPPING,
    AutoFeatureExtractor,
    AutoModelForObjectDetection,
    ObjectDetectionPipeline,
    is_vision_available,
    pipeline,
)
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_pytesseract,
    require_tf,
    require_timm,
    require_torch,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
			from PIL import Image
else:






			class _UpperCamelCase				:
						'''simple docstring'''







						@staticmethod
						def 				__UpperCamelCase			(      *a				:			str   ,   **a				:			int						)				->							str:

							"""simple docstring"""

							pass






@is_pipeline_test
@require_vision
@require_timm
@require_torch
class _UpperCamelCase				(				unittest.TestCase ):
			'''simple docstring'''







			lowerCamelCase__							     =MODEL_FOR_OBJECT_DETECTION_MAPPING
			def 				__UpperCamelCase			(      self				:			Optional[Any]   ,   a				:			str   ,   a				:			Optional[Any]   ,   a				:			Union[str, Any]						)				->							List[Any]:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Dict					  =							ObjectDetectionPipeline(model=a   ,   image_processor=a						)
				return object_detector, ["./tests/fixtures/tests_samples/COCO/000000039769.png"]
			def 				__UpperCamelCase			(      self				:			List[Any]   ,   a				:			Optional[int]   ,   a				:			Optional[int]						)				->							int:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							object_detector("./tests/fixtures/tests_samples/COCO/000000039769.png"   ,   threshold=0.0						)

				self.assertGreater(len(a						)   ,   0						)
				for detected_object in outputs:
					self.assertEqual(
					    a   ,   {
					        "score": ANY(a						),
					        "label": ANY(a						),
					        "box": {"xmin": ANY(a						), "ymin": ANY(a						), "xmax": ANY(a						), "ymax": ANY(a						)},
					    }   ,   )

				import datasets

				SCREAMING_SNAKE_CASE :   Any					  =							datasets.load_dataset("hf-internal-testing/fixtures_image_utils"   ,   "image"   ,   split="test"						)

				SCREAMING_SNAKE_CASE :   Dict					  =							[
				    Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"						),
				    "http://images.cocodataset.org/val2017/000000039769.jpg",
				    # RGBA
				    dataset[0]["file"],
				    # LA
				    dataset[1]["file"],
				    # L
				    dataset[2]["file"],
				]
				SCREAMING_SNAKE_CASE :   Tuple					  =							object_detector(a   ,   threshold=0.0						)

				self.assertEqual(len(a						)   ,   len(a						)						)
				for outputs in batch_outputs:
					self.assertGreater(len(a						)   ,   0						)
					for detected_object in outputs:
						self.assertEqual(
						    a   ,   {
						        "score": ANY(a						),
						        "label": ANY(a						),
						        "box": {"xmin": ANY(a						), "ymin": ANY(a						), "xmax": ANY(a						), "ymax": ANY(a						)},
						    }   ,   )
			@require_tf
			@unittest.skip("Object detection not implemented in TF"						)
			def 				__UpperCamelCase			(      self				:			Optional[int]						)				->							str:

				"""simple docstring"""

				pass
			@require_torch
			def 				__UpperCamelCase			(      self				:			Tuple						)				->							List[Any]:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   str					  =							"hf-internal-testing/tiny-detr-mobilenetsv3"

				SCREAMING_SNAKE_CASE :   Dict					  =							AutoModelForObjectDetection.from_pretrained(a						)
				SCREAMING_SNAKE_CASE :   Any					  =							AutoFeatureExtractor.from_pretrained(a						)
				SCREAMING_SNAKE_CASE :   Tuple					  =							ObjectDetectionPipeline(model=a   ,   feature_extractor=a						)

				SCREAMING_SNAKE_CASE :   int					  =							object_detector("http://images.cocodataset.org/val2017/000000039769.jpg"   ,   threshold=0.0						)

				self.assertEqual(
				    nested_simplify(a   ,   decimals=4						)   ,   [
				        {"score": 0.3376, "label": "LABEL_0", "box": {"xmin": 159, "ymin": 120, "xmax": 480, "ymax": 359}},
				        {"score": 0.3376, "label": "LABEL_0", "box": {"xmin": 159, "ymin": 120, "xmax": 480, "ymax": 359}},
				    ]   ,   )

				SCREAMING_SNAKE_CASE :   Dict					  =							object_detector(
				    [
				        "http://images.cocodataset.org/val2017/000000039769.jpg",
				        "http://images.cocodataset.org/val2017/000000039769.jpg",
				    ]   ,   threshold=0.0   ,   )

				self.assertEqual(
				    nested_simplify(a   ,   decimals=4						)   ,   [
				        [
				            {"score": 0.3376, "label": "LABEL_0", "box": {"xmin": 159, "ymin": 120, "xmax": 480, "ymax": 359}},
				            {"score": 0.3376, "label": "LABEL_0", "box": {"xmin": 159, "ymin": 120, "xmax": 480, "ymax": 359}},
				        ],
				        [
				            {"score": 0.3376, "label": "LABEL_0", "box": {"xmin": 159, "ymin": 120, "xmax": 480, "ymax": 359}},
				            {"score": 0.3376, "label": "LABEL_0", "box": {"xmin": 159, "ymin": 120, "xmax": 480, "ymax": 359}},
				        ],
				    ]   ,   )
			@require_torch
			@slow
			def 				__UpperCamelCase			(      self				:			str						)				->							List[Any]:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Dict					  =							"facebook/detr-resnet-50"

				SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							AutoModelForObjectDetection.from_pretrained(a						)
				SCREAMING_SNAKE_CASE :   List[str]					  =							AutoFeatureExtractor.from_pretrained(a						)
				SCREAMING_SNAKE_CASE :   int					  =							ObjectDetectionPipeline(model=a   ,   feature_extractor=a						)

				SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							object_detector("http://images.cocodataset.org/val2017/000000039769.jpg"						)
				self.assertEqual(
				    nested_simplify(a   ,   decimals=4						)   ,   [
				        {"score": 0.9982, "label": "remote", "box": {"xmin": 40, "ymin": 70, "xmax": 175, "ymax": 117}},
				        {"score": 0.9960, "label": "remote", "box": {"xmin": 333, "ymin": 72, "xmax": 368, "ymax": 187}},
				        {"score": 0.9955, "label": "couch", "box": {"xmin": 0, "ymin": 1, "xmax": 639, "ymax": 473}},
				        {"score": 0.9988, "label": "cat", "box": {"xmin": 13, "ymin": 52, "xmax": 314, "ymax": 470}},
				        {"score": 0.9987, "label": "cat", "box": {"xmin": 345, "ymin": 23, "xmax": 640, "ymax": 368}},
				    ]   ,   )

				SCREAMING_SNAKE_CASE :   int					  =							object_detector(
				    [
				        "http://images.cocodataset.org/val2017/000000039769.jpg",
				        "http://images.cocodataset.org/val2017/000000039769.jpg",
				    ]						)
				self.assertEqual(
				    nested_simplify(a   ,   decimals=4						)   ,   [
				        [
				            {"score": 0.9982, "label": "remote", "box": {"xmin": 40, "ymin": 70, "xmax": 175, "ymax": 117}},
				            {"score": 0.9960, "label": "remote", "box": {"xmin": 333, "ymin": 72, "xmax": 368, "ymax": 187}},
				            {"score": 0.9955, "label": "couch", "box": {"xmin": 0, "ymin": 1, "xmax": 639, "ymax": 473}},
				            {"score": 0.9988, "label": "cat", "box": {"xmin": 13, "ymin": 52, "xmax": 314, "ymax": 470}},
				            {"score": 0.9987, "label": "cat", "box": {"xmin": 345, "ymin": 23, "xmax": 640, "ymax": 368}},
				        ],
				        [
				            {"score": 0.9982, "label": "remote", "box": {"xmin": 40, "ymin": 70, "xmax": 175, "ymax": 117}},
				            {"score": 0.9960, "label": "remote", "box": {"xmin": 333, "ymin": 72, "xmax": 368, "ymax": 187}},
				            {"score": 0.9955, "label": "couch", "box": {"xmin": 0, "ymin": 1, "xmax": 639, "ymax": 473}},
				            {"score": 0.9988, "label": "cat", "box": {"xmin": 13, "ymin": 52, "xmax": 314, "ymax": 470}},
				            {"score": 0.9987, "label": "cat", "box": {"xmin": 345, "ymin": 23, "xmax": 640, "ymax": 368}},
				        ],
				    ]   ,   )
			@require_torch
			@slow
			def 				__UpperCamelCase			(      self				:			str						)				->							str:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Tuple					  =							"facebook/detr-resnet-50"

				SCREAMING_SNAKE_CASE :   Tuple					  =							pipeline("object-detection"   ,   model=a						)

				SCREAMING_SNAKE_CASE :   Tuple					  =							object_detector("http://images.cocodataset.org/val2017/000000039769.jpg"						)
				self.assertEqual(
				    nested_simplify(a   ,   decimals=4						)   ,   [
				        {"score": 0.9982, "label": "remote", "box": {"xmin": 40, "ymin": 70, "xmax": 175, "ymax": 117}},
				        {"score": 0.9960, "label": "remote", "box": {"xmin": 333, "ymin": 72, "xmax": 368, "ymax": 187}},
				        {"score": 0.9955, "label": "couch", "box": {"xmin": 0, "ymin": 1, "xmax": 639, "ymax": 473}},
				        {"score": 0.9988, "label": "cat", "box": {"xmin": 13, "ymin": 52, "xmax": 314, "ymax": 470}},
				        {"score": 0.9987, "label": "cat", "box": {"xmin": 345, "ymin": 23, "xmax": 640, "ymax": 368}},
				    ]   ,   )

				SCREAMING_SNAKE_CASE :   str					  =							object_detector(
				    [
				        "http://images.cocodataset.org/val2017/000000039769.jpg",
				        "http://images.cocodataset.org/val2017/000000039769.jpg",
				    ]						)
				self.assertEqual(
				    nested_simplify(a   ,   decimals=4						)   ,   [
				        [
				            {"score": 0.9982, "label": "remote", "box": {"xmin": 40, "ymin": 70, "xmax": 175, "ymax": 117}},
				            {"score": 0.9960, "label": "remote", "box": {"xmin": 333, "ymin": 72, "xmax": 368, "ymax": 187}},
				            {"score": 0.9955, "label": "couch", "box": {"xmin": 0, "ymin": 1, "xmax": 639, "ymax": 473}},
				            {"score": 0.9988, "label": "cat", "box": {"xmin": 13, "ymin": 52, "xmax": 314, "ymax": 470}},
				            {"score": 0.9987, "label": "cat", "box": {"xmin": 345, "ymin": 23, "xmax": 640, "ymax": 368}},
				        ],
				        [
				            {"score": 0.9982, "label": "remote", "box": {"xmin": 40, "ymin": 70, "xmax": 175, "ymax": 117}},
				            {"score": 0.9960, "label": "remote", "box": {"xmin": 333, "ymin": 72, "xmax": 368, "ymax": 187}},
				            {"score": 0.9955, "label": "couch", "box": {"xmin": 0, "ymin": 1, "xmax": 639, "ymax": 473}},
				            {"score": 0.9988, "label": "cat", "box": {"xmin": 13, "ymin": 52, "xmax": 314, "ymax": 470}},
				            {"score": 0.9987, "label": "cat", "box": {"xmin": 345, "ymin": 23, "xmax": 640, "ymax": 368}},
				        ],
				    ]   ,   )
			@require_torch
			@slow
			def 				__UpperCamelCase			(      self				:			str						)				->							str:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Optional[int]					  =							0.9985
				SCREAMING_SNAKE_CASE :   int					  =							"facebook/detr-resnet-50"

				SCREAMING_SNAKE_CASE :   List[str]					  =							pipeline("object-detection"   ,   model=a						)

				SCREAMING_SNAKE_CASE :   str					  =							object_detector("http://images.cocodataset.org/val2017/000000039769.jpg"   ,   threshold=a						)
				self.assertEqual(
				    nested_simplify(a   ,   decimals=4						)   ,   [
				        {"score": 0.9988, "label": "cat", "box": {"xmin": 13, "ymin": 52, "xmax": 314, "ymax": 470}},
				        {"score": 0.9987, "label": "cat", "box": {"xmin": 345, "ymin": 23, "xmax": 640, "ymax": 368}},
				    ]   ,   )






			@require_torch
			@require_pytesseract
			@slow
			def 				__UpperCamelCase			(      self				:			str						)				->							Tuple:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Any					  =							"Narsil/layoutlmv3-finetuned-funsd"
				SCREAMING_SNAKE_CASE :   Dict					  =							0.9993

				SCREAMING_SNAKE_CASE :   str					  =							pipeline("object-detection"   ,   model=a   ,   threshold=a						)

				SCREAMING_SNAKE_CASE :   List[Any]					  =							object_detector(
				    "https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png"						)
				self.assertEqual(
				    nested_simplify(a   ,   decimals=4						)   ,   [
				        {"score": 0.9993, "label": "I-ANSWER", "box": {"xmin": 294, "ymin": 254, "xmax": 343, "ymax": 264}},
				        {"score": 0.9993, "label": "I-ANSWER", "box": {"xmin": 294, "ymin": 254, "xmax": 343, "ymax": 264}},
				    ]   ,   )