




'''simple docstring'''

import re


def 		__magic_name__    (	__UpperCAmelCase	)		->					bool:

					'''simple docstring'''

					snake_case_									=				re.compile(
					    r'''^(?:0|94|\+94|0{2}94)''' r'''7(0|1|2|4|5|6|7|8)''' r'''(-| |)''' r'''\d{7}$'''	)

					return bool(re.search(__UpperCAmelCase,      __UpperCAmelCase	)	)


if __name__ == "__main__":
							a  :				Any									=  '0094702343221'

							print(is_sri_lankan_phone_number(phone))







'''simple docstring'''

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 						a				:


											@staticmethod
											def   A_ (		*lowercase_    :					int       ,				**lowercase_    :					str					):
																pass






@is_pipeline_test
@require_vision
@require_timm
@require_torch
class 						a				(   unittest.TestCase     ):
				snake_case_      =		MODEL_FOR_OBJECT_DETECTION_MAPPING


				def   A_ (		self    :					Any       ,				lowercase_    :					List[Any]       ,				lowercase_    :					Optional[int]       ,				lowercase_    :					List[str]					):
									snake_case_									=				ObjectDetectionPipeline(model=lowercase_       ,				image_processor=lowercase_					)
									return object_detector, ["./tests/fixtures/tests_samples/COCO/000000039769.png"]


				def   A_ (		self    :					Dict       ,				lowercase_    :					List[Any]       ,				lowercase_    :					int					):
									snake_case_									=				object_detector('''./tests/fixtures/tests_samples/COCO/000000039769.png'''       ,				threshold=0.0					)

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

									import datasets

									snake_case_									=				datasets.load_dataset('''hf-internal-testing/fixtures_image_utils'''       ,				'''image'''       ,				split='''test'''					)

									snake_case_									=				[
									    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'''],
									]
									snake_case_									=				object_detector(lowercase_       ,				threshold=0.0					)

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


				@require_tf
				@unittest.skip('''Object detection not implemented in TF'''					)
				def   A_ (		self    :					int					):
									pass


				@require_torch
				def   A_ (		self    :					Tuple					):
									snake_case_									=				'''hf-internal-testing/tiny-detr-mobilenetsv3'''

									snake_case_									=				AutoModelForObjectDetection.from_pretrained(lowercase_					)
									snake_case_									=				AutoFeatureExtractor.from_pretrained(lowercase_					)
									snake_case_									=				ObjectDetectionPipeline(model=lowercase_       ,				feature_extractor=lowercase_					)

									snake_case_									=				object_detector('''http://images.cocodataset.org/val2017/000000039769.jpg'''       ,				threshold=0.0					)

									self.assertEqual(
									    nested_simplify(lowercase_       ,				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}},
									    ]       ,				)

									snake_case_									=				object_detector(
									    [
									        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
									        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
									    ]       ,				threshold=0.0       ,				)

									self.assertEqual(
									    nested_simplify(lowercase_       ,				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   A_ (		self    :					Optional[int]					):
									snake_case_									=				'''facebook/detr-resnet-50'''

									snake_case_									=				AutoModelForObjectDetection.from_pretrained(lowercase_					)
									snake_case_									=				AutoFeatureExtractor.from_pretrained(lowercase_					)
									snake_case_									=				ObjectDetectionPipeline(model=lowercase_       ,				feature_extractor=lowercase_					)

									snake_case_									=				object_detector('''http://images.cocodataset.org/val2017/000000039769.jpg'''					)
									self.assertEqual(
									    nested_simplify(lowercase_       ,				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}},
									    ]       ,				)

									snake_case_									=				object_detector(
									    [
									        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
									        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
									    ]					)
									self.assertEqual(
									    nested_simplify(lowercase_       ,				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   A_ (		self    :					Tuple					):
									snake_case_									=				'''facebook/detr-resnet-50'''

									snake_case_									=				pipeline('''object-detection'''       ,				model=lowercase_					)

									snake_case_									=				object_detector('''http://images.cocodataset.org/val2017/000000039769.jpg'''					)
									self.assertEqual(
									    nested_simplify(lowercase_       ,				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}},
									    ]       ,				)

									snake_case_									=				object_detector(
									    [
									        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
									        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
									    ]					)
									self.assertEqual(
									    nested_simplify(lowercase_       ,				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   A_ (		self    :					str					):
									snake_case_									=				0.9985
									snake_case_									=				'''facebook/detr-resnet-50'''

									snake_case_									=				pipeline('''object-detection'''       ,				model=lowercase_					)

									snake_case_									=				object_detector('''http://images.cocodataset.org/val2017/000000039769.jpg'''       ,				threshold=lowercase_					)
									self.assertEqual(
									    nested_simplify(lowercase_       ,				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   A_ (		self    :					Dict					):
									snake_case_									=				'''Narsil/layoutlmv3-finetuned-funsd'''
									snake_case_									=				0.9993

									snake_case_									=				pipeline('''object-detection'''       ,				model=lowercase_       ,				threshold=lowercase_					)

									snake_case_									=				object_detector(
									    '''https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png'''					)
									self.assertEqual(
									    nested_simplify(lowercase_       ,				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}},
									    ]       ,				)

