






from __future__ import annotations

import os
import tempfile
import unittest

from transformers import ConvBertConfig, is_tf_available
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 (
				    TFConvBertForMaskedLM,
				    TFConvBertForMultipleChoice,
				    TFConvBertForQuestionAnswering,
				    TFConvBertForSequenceClassification,
				    TFConvBertForTokenClassification,
				    TFConvBertModel,
				)

class 		__A  :






			def __init__(       self		,					a		,					a=13		,					a=7		,					a=True		,					a=True		,					a=True		,					a=True		,					a=99		,					a=32		,					a=2		,					a=4		,					a=37		,					a="gelu"		,					a=0.1		,					a=0.1		,					a=512		,					a=16		,					a=2		,					a=0.02		,					a=3		,					a=4		,					a=None		,					)      ->       Any:
						SCREAMING_SNAKE_CASE						= parent
						SCREAMING_SNAKE_CASE						= 13
						SCREAMING_SNAKE_CASE						= 7
						SCREAMING_SNAKE_CASE						= True
						SCREAMING_SNAKE_CASE						= True
						SCREAMING_SNAKE_CASE						= True
						SCREAMING_SNAKE_CASE						= True
						SCREAMING_SNAKE_CASE						= 99
						SCREAMING_SNAKE_CASE						= 384
						SCREAMING_SNAKE_CASE						= 2
						SCREAMING_SNAKE_CASE						= 4
						SCREAMING_SNAKE_CASE						= 37
						SCREAMING_SNAKE_CASE						= '''gelu'''
						SCREAMING_SNAKE_CASE						= 0.1
						SCREAMING_SNAKE_CASE						= 0.1
						SCREAMING_SNAKE_CASE						= 512
						SCREAMING_SNAKE_CASE						= 16
						SCREAMING_SNAKE_CASE						= 2
						SCREAMING_SNAKE_CASE						= 0.02
						SCREAMING_SNAKE_CASE						= 3
						SCREAMING_SNAKE_CASE						= 4
						SCREAMING_SNAKE_CASE						= 128
						SCREAMING_SNAKE_CASE						= 2
						SCREAMING_SNAKE_CASE						= 9
						SCREAMING_SNAKE_CASE						= 1
						SCREAMING_SNAKE_CASE						= None






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       List[str]:
						SCREAMING_SNAKE_CASE						= ids_tensor([self.batch_size, self.seq_length]		,					self.vocab_size)

						SCREAMING_SNAKE_CASE						= None
						if self.use_input_mask:
									SCREAMING_SNAKE_CASE						= random_attention_mask([self.batch_size, self.seq_length])

						SCREAMING_SNAKE_CASE						= None
						if self.use_token_type_ids:
									SCREAMING_SNAKE_CASE						= ids_tensor([self.batch_size, self.seq_length]		,					self.type_vocab_size)

						SCREAMING_SNAKE_CASE						= None
						SCREAMING_SNAKE_CASE						= None
						SCREAMING_SNAKE_CASE						= None
						if self.use_labels:
									SCREAMING_SNAKE_CASE						= ids_tensor([self.batch_size]		,					self.type_sequence_label_size)
									SCREAMING_SNAKE_CASE						= ids_tensor([self.batch_size, self.seq_length]		,					self.num_labels)
									SCREAMING_SNAKE_CASE						= ids_tensor([self.batch_size]		,					self.num_choices)

						SCREAMING_SNAKE_CASE						= ConvBertConfig(
						    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		,					return_dict=UpperCamelCase__		,					)

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






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a		,					a		,					a		,					a		,					a		,					a)      ->       int:
						SCREAMING_SNAKE_CASE						= TFConvBertModel(config=UpperCamelCase__)
						SCREAMING_SNAKE_CASE						= {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}

						SCREAMING_SNAKE_CASE						= [input_ids, input_mask]
						SCREAMING_SNAKE_CASE						= model(UpperCamelCase__)

						SCREAMING_SNAKE_CASE						= model(UpperCamelCase__)

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






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a		,					a		,					a		,					a		,					a		,					a)      ->       Tuple:
						SCREAMING_SNAKE_CASE						= TFConvBertForMaskedLM(config=UpperCamelCase__)
						SCREAMING_SNAKE_CASE						= {
						    '''input_ids''': input_ids,
						    '''attention_mask''': input_mask,
						    '''token_type_ids''': token_type_ids,
						}
						SCREAMING_SNAKE_CASE						= model(UpperCamelCase__)
						self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.seq_length, self.vocab_size))






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a		,					a		,					a		,					a		,					a		,					a)      ->       Optional[int]:
						SCREAMING_SNAKE_CASE						= self.num_labels
						SCREAMING_SNAKE_CASE						= TFConvBertForSequenceClassification(config=UpperCamelCase__)
						SCREAMING_SNAKE_CASE						= {
						    '''input_ids''': input_ids,
						    '''attention_mask''': input_mask,
						    '''token_type_ids''': token_type_ids,
						}

						SCREAMING_SNAKE_CASE						= model(UpperCamelCase__)
						self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.num_labels))






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a		,					a		,					a		,					a		,					a		,					a)      ->       Any:
						SCREAMING_SNAKE_CASE						= self.num_choices
						SCREAMING_SNAKE_CASE						= TFConvBertForMultipleChoice(config=UpperCamelCase__)
						SCREAMING_SNAKE_CASE						= tf.tile(tf.expand_dims(UpperCamelCase__		,					1)		,					(1, self.num_choices, 1))
						SCREAMING_SNAKE_CASE						= tf.tile(tf.expand_dims(UpperCamelCase__		,					1)		,					(1, self.num_choices, 1))
						SCREAMING_SNAKE_CASE						= tf.tile(tf.expand_dims(UpperCamelCase__		,					1)		,					(1, self.num_choices, 1))
						SCREAMING_SNAKE_CASE						= {
						    '''input_ids''': multiple_choice_inputs_ids,
						    '''attention_mask''': multiple_choice_input_mask,
						    '''token_type_ids''': multiple_choice_token_type_ids,
						}
						SCREAMING_SNAKE_CASE						= model(UpperCamelCase__)
						self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.num_choices))






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a		,					a		,					a		,					a		,					a		,					a)      ->       List[Any]:
						SCREAMING_SNAKE_CASE						= self.num_labels
						SCREAMING_SNAKE_CASE						= TFConvBertForTokenClassification(config=UpperCamelCase__)
						SCREAMING_SNAKE_CASE						= {
						    '''input_ids''': input_ids,
						    '''attention_mask''': input_mask,
						    '''token_type_ids''': token_type_ids,
						}
						SCREAMING_SNAKE_CASE						= model(UpperCamelCase__)
						self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.seq_length, self.num_labels))






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a		,					a		,					a		,					a		,					a		,					a)      ->       str:
						SCREAMING_SNAKE_CASE						= TFConvBertForQuestionAnswering(config=UpperCamelCase__)
						SCREAMING_SNAKE_CASE						= {
						    '''input_ids''': input_ids,
						    '''attention_mask''': input_mask,
						    '''token_type_ids''': token_type_ids,
						}

						SCREAMING_SNAKE_CASE						= model(UpperCamelCase__)
						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    SCREAMING_SNAKE_CASE__    (       self)      ->       Union[str, Any]:
						SCREAMING_SNAKE_CASE						= self.prepare_config_and_inputs()
						(
						    SCREAMING_SNAKE_CASE						
						)						= config_and_inputs
						SCREAMING_SNAKE_CASE						= {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
						return config, inputs_dict



@require_tf
class 		__A  (  UpperCamelCase_   ,    UpperCamelCase_   ,    unittest.TestCase					):
			_lowercase		:    Dict			     =							(
			    (
			        TFConvBertModel,
			        TFConvBertForMaskedLM,
			        TFConvBertForQuestionAnswering,
			        TFConvBertForSequenceClassification,
			        TFConvBertForTokenClassification,
			        TFConvBertForMultipleChoice,
			    )
			    if is_tf_available()
			    else ()
			)
			_lowercase		:    int			     =							(
			    {
			        '''feature-extraction''': TFConvBertModel,
			        '''fill-mask''': TFConvBertForMaskedLM,
			        '''question-answering''': TFConvBertForQuestionAnswering,
			        '''text-classification''': TFConvBertForSequenceClassification,
			        '''token-classification''': TFConvBertForTokenClassification,
			        '''zero-shot''': TFConvBertForSequenceClassification,
			    }
			    if is_tf_available()
			    else {}
			)
			_lowercase		:    int			     =							False
			_lowercase		:    List[Any]			     =							False
			_lowercase		:    Dict			     =							False






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       List[str]:
						SCREAMING_SNAKE_CASE						= TFConvBertModelTester(self)
						SCREAMING_SNAKE_CASE						= ConfigTester(self		,					config_class=UpperCamelCase__		,					hidden_size=37)






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Any:
						self.config_tester.run_common_tests()






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       str:
						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*UpperCamelCase__)






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Any:
						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_masked_lm(*UpperCamelCase__)






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Tuple:
						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_multiple_choice(*UpperCamelCase__)






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Any:
						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_question_answering(*UpperCamelCase__)






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       int:
						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_sequence_classification(*UpperCamelCase__)






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       List[str]:
						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_token_classification(*UpperCamelCase__)






			@slow
			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Any:
						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs_for_common()
						SCREAMING_SNAKE_CASE						= True
						SCREAMING_SNAKE_CASE						= True

						if hasattr(UpperCamelCase__		,					'use_cache'):
									SCREAMING_SNAKE_CASE						= True

						SCREAMING_SNAKE_CASE						= getattr(self.model_tester		,					'encoder_seq_length'		,					self.model_tester.seq_length)
						SCREAMING_SNAKE_CASE						= getattr(self.model_tester		,					'key_length'		,					UpperCamelCase__)

						for model_class in self.all_model_classes:
									SCREAMING_SNAKE_CASE						= self._prepare_for_class(UpperCamelCase__		,					UpperCamelCase__)
									SCREAMING_SNAKE_CASE						= model_class(UpperCamelCase__)
									SCREAMING_SNAKE_CASE						= len(model(UpperCamelCase__))

									with tempfile.TemporaryDirectory() as tmpdirname:
												model.save_pretrained(UpperCamelCase__		,					saved_model=UpperCamelCase__)
												SCREAMING_SNAKE_CASE						= os.path.join(UpperCamelCase__		,					'saved_model'		,					'1')
												SCREAMING_SNAKE_CASE						= tf.keras.models.load_model(UpperCamelCase__)
												SCREAMING_SNAKE_CASE						= model(UpperCamelCase__)

												if self.is_encoder_decoder:
															SCREAMING_SNAKE_CASE						= outputs['''encoder_hidden_states''']
															SCREAMING_SNAKE_CASE						= outputs['''encoder_attentions''']
												else:
															SCREAMING_SNAKE_CASE						= outputs['''hidden_states''']
															SCREAMING_SNAKE_CASE						= outputs['''attentions''']

												self.assertEqual(len(UpperCamelCase__)		,					UpperCamelCase__)

												SCREAMING_SNAKE_CASE						= getattr(
												    self.model_tester		,					'expected_num_hidden_layers'		,					self.model_tester.num_hidden_layers + 1)

												self.assertEqual(len(UpperCamelCase__)		,					UpperCamelCase__)
												self.assertListEqual(
												    list(output_hidden_states[0].shape[-2:])		,					[self.model_tester.seq_length, self.model_tester.hidden_size]		,					)

												self.assertEqual(len(UpperCamelCase__)		,					self.model_tester.num_hidden_layers)
												self.assertListEqual(
												    list(output_attentions[0].shape[-3:])		,					[self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]		,					)






			@slow
			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Any:
						SCREAMING_SNAKE_CASE						= TFConvBertModel.from_pretrained('YituTech/conv-bert-base')
						self.assertIsNotNone(UpperCamelCase__)







			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Any:
						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs_for_common()
						SCREAMING_SNAKE_CASE						= True
						SCREAMING_SNAKE_CASE						= getattr(self.model_tester		,					'decoder_seq_length'		,					self.model_tester.seq_length)
						SCREAMING_SNAKE_CASE						= getattr(self.model_tester		,					'encoder_seq_length'		,					self.model_tester.seq_length)
						SCREAMING_SNAKE_CASE						= getattr(self.model_tester		,					'key_length'		,					UpperCamelCase__)
						SCREAMING_SNAKE_CASE						= getattr(self.model_tester		,					'key_length'		,					UpperCamelCase__)

						def check_decoder_attentions_output(a):
									SCREAMING_SNAKE_CASE						= len(UpperCamelCase__)
									self.assertEqual(out_len % 2		,					0)
									SCREAMING_SNAKE_CASE						= outputs.decoder_attentions
									self.assertEqual(len(UpperCamelCase__)		,					self.model_tester.num_hidden_layers)
									self.assertListEqual(
									    list(decoder_attentions[0].shape[-3:])		,					[self.model_tester.num_attention_heads / 2, decoder_seq_length, decoder_key_length]		,					)

						def check_encoder_attentions_output(a):
									SCREAMING_SNAKE_CASE						= [
									    t.numpy() for t in (outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions)
									]
									self.assertEqual(len(UpperCamelCase__)		,					self.model_tester.num_hidden_layers)
									self.assertListEqual(
									    list(attentions[0].shape[-3:])		,					[self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]		,					)

						for model_class in self.all_model_classes:
									SCREAMING_SNAKE_CASE						= True
									SCREAMING_SNAKE_CASE						= False
									SCREAMING_SNAKE_CASE						= model_class(UpperCamelCase__)
									SCREAMING_SNAKE_CASE						= model(self._prepare_for_class(UpperCamelCase__		,					UpperCamelCase__))
									SCREAMING_SNAKE_CASE						= len(UpperCamelCase__)
									self.assertEqual(config.output_hidden_states		,					UpperCamelCase__)
									check_encoder_attentions_output(UpperCamelCase__)

									if self.is_encoder_decoder:
												SCREAMING_SNAKE_CASE						= model_class(UpperCamelCase__)
												SCREAMING_SNAKE_CASE						= model(self._prepare_for_class(UpperCamelCase__		,					UpperCamelCase__))
												self.assertEqual(config.output_hidden_states		,					UpperCamelCase__)
												check_decoder_attentions_output(UpperCamelCase__)

									# Check that output attentions can also be changed via the config
									del inputs_dict["output_attentions"]
									SCREAMING_SNAKE_CASE						= True
									SCREAMING_SNAKE_CASE						= model_class(UpperCamelCase__)
									SCREAMING_SNAKE_CASE						= model(self._prepare_for_class(UpperCamelCase__		,					UpperCamelCase__))
									self.assertEqual(config.output_hidden_states		,					UpperCamelCase__)
									check_encoder_attentions_output(UpperCamelCase__)

									# Check attention is always last and order is fine
									SCREAMING_SNAKE_CASE						= True
									SCREAMING_SNAKE_CASE						= True
									SCREAMING_SNAKE_CASE						= model_class(UpperCamelCase__)
									SCREAMING_SNAKE_CASE						= model(self._prepare_for_class(UpperCamelCase__		,					UpperCamelCase__))

									self.assertEqual(out_len + (2 if self.is_encoder_decoder else 1)		,					len(UpperCamelCase__))
									self.assertEqual(model.config.output_hidden_states		,					UpperCamelCase__)
									check_encoder_attentions_output(UpperCamelCase__)



@require_tf
class 		__A  (  unittest.TestCase					):






			@slow
			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Dict:
						SCREAMING_SNAKE_CASE						= TFConvBertModel.from_pretrained('YituTech/conv-bert-base')
						SCREAMING_SNAKE_CASE						= tf.constant([[0, 1, 2, 3, 4, 5]])
						SCREAMING_SNAKE_CASE						= model(UpperCamelCase__)[0]

						SCREAMING_SNAKE_CASE						= [1, 6, 768]
						self.assertEqual(output.shape		,					UpperCamelCase__)

						SCREAMING_SNAKE_CASE						= tf.constant(
						    [
						        [
						            [-0.03_47_54_93, -0.4_68_60_34, -0.30_63_88_32],
						            [0.22_63_72_48, -0.26_98_86_46, -0.7_42_34_24],
						            [0.10_32_48_68, -0.45_01_35_08, -0.58_28_07_84],
						        ]
						    ])
						tf.debugging.assert_near(output[:, :3, :3]		,					UpperCamelCase__		,					atol=1E-4)












from typing import Any, Dict, List, Union

from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_vision_available():
				from ..image_utils import load_image


if is_torch_available():
				import torch

				from ..models.auto.modeling_auto import MODEL_FOR_OBJECT_DETECTION_MAPPING, MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING

a_		:						str             =    logging.get_logger(__name__)


a_		:						List[Any]             =    Dict[str, Any]
a_		:						Optional[int]             =    List[Prediction]

@add_end_docstrings(A__					)
class 		_snake_case  (  A__					):






			def __init__(       self		,					*a		,					**a)      ->       int:
						super().__init__(*a		,					**a)

						if self.framework == "tf":
									raise ValueError(f'''The {self.__class__} is only available in PyTorch.''')

						requires_backends(self		,					'vision')
						self.check_model_type(
						    dict(MODEL_FOR_OBJECT_DETECTION_MAPPING.items() + MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING.items()))






			def    SCREAMING_SNAKE_CASE__    (       self		,					**a)      ->       int:
						SCREAMING_SNAKE_CASE						= {}
						if "threshold" in kwargs:
									SCREAMING_SNAKE_CASE						= kwargs['threshold']
						return {}, {}, postprocess_kwargs






			def __call__(       self		,					*a		,					**a)      ->       Union[Predictions, List[Prediction]]:
						return super().__call__(*a		,					**a)






			def    SCREAMING_SNAKE_CASE__    (       self		,					a)      ->       List[str]:
						SCREAMING_SNAKE_CASE						= load_image(a)
						SCREAMING_SNAKE_CASE						= torch.IntTensor([[image.height, image.width]])
						SCREAMING_SNAKE_CASE						= self.image_processor(images=[image]		,					return_tensors='pt')
						if self.tokenizer is not None:
									SCREAMING_SNAKE_CASE						= self.tokenizer(text=inputs['words']		,					boxes=inputs['boxes']		,					return_tensors='pt')
						SCREAMING_SNAKE_CASE						= target_size
						return inputs






			def    SCREAMING_SNAKE_CASE__    (       self		,					a)      ->       int:
						SCREAMING_SNAKE_CASE						= model_inputs.pop('target_size')
						SCREAMING_SNAKE_CASE						= self.model(**a)
						SCREAMING_SNAKE_CASE						= outputs.__class__({'target_size': target_size, **outputs})
						if self.tokenizer is not None:
									SCREAMING_SNAKE_CASE						= model_inputs['bbox']
						return model_outputs






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a=0.9)      ->       Dict:
						SCREAMING_SNAKE_CASE						= model_outputs['target_size']
						if self.tokenizer is not None:
									# This is a LayoutLMForTokenClassification variant.
									# The OCR got the boxes and the model classified the words.
									SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE						= target_size[0].tolist()

									def unnormalize(a):
												return self._get_bounding_box(
												    torch.Tensor(
												        [
												            (width * bbox[0] / 1000),
												            (height * bbox[1] / 1000),
												            (width * bbox[2] / 1000),
												            (height * bbox[3] / 1000),
												        ]))

									SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE						= model_outputs['logits'].squeeze(0).softmax(dim=-1).max(dim=-1)
									SCREAMING_SNAKE_CASE						= [self.model.config.idalabel[prediction] for prediction in classes.tolist()]
									SCREAMING_SNAKE_CASE						= [unnormalize(a) for bbox in model_outputs['bbox'].squeeze(0)]
									SCREAMING_SNAKE_CASE						= ['score', 'label', 'box']
									SCREAMING_SNAKE_CASE						= [dict(zip(a		,					a)) for vals in zip(scores.tolist()		,					a		,					a) if vals[0] > threshold]
						else:
									# This is a regular ForObjectDetectionModel
									SCREAMING_SNAKE_CASE						= self.image_processor.post_process_object_detection(a		,					a		,					a)
									SCREAMING_SNAKE_CASE						= raw_annotations[0]
									SCREAMING_SNAKE_CASE						= raw_annotation['scores']
									SCREAMING_SNAKE_CASE						= raw_annotation['labels']
									SCREAMING_SNAKE_CASE						= raw_annotation['boxes']

									SCREAMING_SNAKE_CASE						= scores.tolist()
									SCREAMING_SNAKE_CASE						= [self.model.config.idalabel[label.item()] for label in labels]
									SCREAMING_SNAKE_CASE						= [self._get_bounding_box(a) for box in boxes]

									# {"scores": [...], ...} --> [{"score":x, ...}, ...]
									SCREAMING_SNAKE_CASE						= ['score', 'label', 'box']
									SCREAMING_SNAKE_CASE						= [
									    dict(zip(a		,					a))
									    for vals in zip(raw_annotation['scores']		,					raw_annotation['labels']		,					raw_annotation['boxes'])
									]

						return annotation







			def    SCREAMING_SNAKE_CASE__    (       self		,					a)      ->       Dict[str, int]:
						if self.framework != "pt":
									raise ValueError('The ObjectDetectionPipeline is only available in PyTorch.')
						SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE						= box.int().tolist()
						SCREAMING_SNAKE_CASE						= {
						    'xmin': xmin,
						    'ymin': ymin,
						    'xmax': xmax,
						    'ymax': ymax,
						}
						return bbox




