


import json
import os
import shutil
import tempfile
from unittest import TestCase

from transformers import BartTokenizer, BartTokenizerFast, DPRQuestionEncoderTokenizer, DPRQuestionEncoderTokenizerFast
from transformers.models.bart.configuration_bart import BartConfig
from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES as DPR_VOCAB_FILES_NAMES
from transformers.models.dpr.configuration_dpr import DPRConfig
from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES as BART_VOCAB_FILES_NAMES
from transformers.testing_utils import require_faiss, require_tokenizers, require_torch, slow
from transformers.utils import is_datasets_available, is_faiss_available, is_torch_available


if is_torch_available() and is_datasets_available() and is_faiss_available():
 from transformers.models.rag.configuration_rag import RagConfig
 from transformers.models.rag.tokenization_rag import RagTokenizer






@require_faiss
@require_torch
class _lowerCamelCase(		_a     ):
       def     UpperCamelCase  (      self) ->     Dict:




           """simple docstring"""

           _lowercase :							Dict   	=	tempfile.mkdtemp()
           _lowercase :							Dict   	=	8

           # DPR tok
           _lowercase :							int   	=	[
               '[UNK]',
               '[CLS]',
               '[SEP]',
               '[PAD]',
               '[MASK]',
               'want',
               '##want',
               '##ed',
               'wa',
               'un',
               'runn',
               '##ing',
               ',',
               'low',
               'lowest',
           ]
           _lowercase :							str   	=	os.path.join(self.tmpdirname,   'dpr_tokenizer')
           os.makedirs(lowerCamelCase,   exist_ok=lowerCamelCase)
           _lowercase :							Optional[Any]   	=	os.path.join(lowerCamelCase,   DPR_VOCAB_FILES_NAMES['vocab_file'])
           with open(self.vocab_file,   'w',   encoding='utf-8') as vocab_writer:
               vocab_writer.write(''.join([x + '\n' for x in vocab_tokens]))

           # BART tok
           _lowercase :							Optional[Any]   	=	[
               'l',
               'o',
               'w',
               'e',
               'r',
               's',
               't',
               'i',
               'd',
               'n',
               '\u0120',
               '\u0120l',
               '\u0120n',
               '\u0120lo',
               '\u0120low',
               'er',
               '\u0120lowest',
               '\u0120newer',
               '\u0120wider',
               '<unk>',
           ]
           _lowercase :							Optional[int]   	=	dict(zip(lowerCamelCase,   range(len(lowerCamelCase))))
           _lowercase :							List[Any]   	=	['#version: 0.2', '\u0120 l', '\u0120l o', '\u0120lo w', 'e r', '']
           _lowercase :							str   	=	{'unk_token': '<unk>'}

           _lowercase :							Union[str, Any]   	=	os.path.join(self.tmpdirname,   'bart_tokenizer')
           os.makedirs(lowerCamelCase,   exist_ok=lowerCamelCase)
           _lowercase :							Dict   	=	os.path.join(lowerCamelCase,   BART_VOCAB_FILES_NAMES['vocab_file'])
           _lowercase :							List[str]   	=	os.path.join(lowerCamelCase,   BART_VOCAB_FILES_NAMES['merges_file'])
           with open(self.vocab_file,   'w',   encoding='utf-8') as fp:
               fp.write(json.dumps(lowerCamelCase) + '\n')
           with open(self.merges_file,   'w',   encoding='utf-8') as fp:
               fp.write('\n'.join(lowerCamelCase))
       def     UpperCamelCase  (      self) ->     DPRQuestionEncoderTokenizer:




           """simple docstring"""

           return DPRQuestionEncoderTokenizer.from_pretrained(os.path.join(self.tmpdirname,   'dpr_tokenizer'))
       def     UpperCamelCase  (      self) ->     BartTokenizer:




           """simple docstring"""

           return BartTokenizer.from_pretrained(os.path.join(self.tmpdirname,   'bart_tokenizer'))
       def     UpperCamelCase  (      self) ->     Dict:




           """simple docstring"""

           shutil.rmtree(self.tmpdirname)
       @require_tokenizers
       def     UpperCamelCase  (      self) ->     Optional[int]:




           """simple docstring"""

           _lowercase :							Dict   	=	os.path.join(self.tmpdirname,   'rag_tokenizer')
           _lowercase :							Optional[int]   	=	RagConfig(question_encoder=DPRConfig().to_dict(),   generator=BartConfig().to_dict())
           _lowercase :							Dict   	=	RagTokenizer(question_encoder=self.get_dpr_tokenizer(),   generator=self.get_bart_tokenizer())
           rag_config.save_pretrained(lowerCamelCase)
           rag_tokenizer.save_pretrained(lowerCamelCase)
           _lowercase :							Union[str, Any]   	=	RagTokenizer.from_pretrained(lowerCamelCase,   config=lowerCamelCase)
           self.assertIsInstance(new_rag_tokenizer.question_encoder,   lowerCamelCase)
           self.assertEqual(new_rag_tokenizer.question_encoder.get_vocab(),   rag_tokenizer.question_encoder.get_vocab())
           self.assertIsInstance(new_rag_tokenizer.generator,   lowerCamelCase)
           self.assertEqual(new_rag_tokenizer.generator.get_vocab(),   rag_tokenizer.generator.get_vocab())
       @slow
       def     UpperCamelCase  (      self) ->     Any:




           """simple docstring"""

           _lowercase :							Dict   	=	RagTokenizer.from_pretrained('facebook/rag-token-nq')
           _lowercase :							Optional[Any]   	=	[
               'who got the first nobel prize in physics',
               'when is the next deadpool movie being released',
               'which mode is used for short wave broadcast service',
               'who is the owner of reading football club',
               'when is the next scandal episode coming out',
               'when is the last time the philadelphia won the superbowl',
               'what is the most current adobe flash player version',
               'how many episodes are there in dragon ball z',
               'what is the first step in the evolution of the eye',
               'where is gall bladder situated in human body',
               'what is the main mineral in lithium batteries',
               'who is the president of usa right now',
               'where do the greasers live in the outsiders',
               'panda is a national animal of which country',
               'what is the name of manchester united stadium',
           ]
           _lowercase :							List[Any]   	=	tokenizer(lowerCamelCase)
           self.assertIsNotNone(lowerCamelCase)




       @slow
       def     UpperCamelCase  (      self) ->     Tuple:




           """simple docstring"""

           _lowercase :							List[str]   	=	RagTokenizer.from_pretrained('facebook/rag-sequence-nq')
           _lowercase :							Optional[int]   	=	[
               'who got the first nobel prize in physics',
               'when is the next deadpool movie being released',
               'which mode is used for short wave broadcast service',
               'who is the owner of reading football club',
               'when is the next scandal episode coming out',
               'when is the last time the philadelphia won the superbowl',
               'what is the most current adobe flash player version',
               'how many episodes are there in dragon ball z',
               'what is the first step in the evolution of the eye',
               'where is gall bladder situated in human body',
               'what is the main mineral in lithium batteries',
               'who is the president of usa right now',
               'where do the greasers live in the outsiders',
               'panda is a national animal of which country',
               'what is the name of manchester united stadium',
           ]
           _lowercase :							str   	=	tokenizer(lowerCamelCase)
           self.assertIsNotNone(lowerCamelCase)






import inspect
import unittest

from transformers import YolosConfig
from transformers.testing_utils import require_torch, 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, floats_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
 import torch
 from torch import nn

 from transformers import YolosForObjectDetection, YolosModel
 from transformers.models.yolos.modeling_yolos import YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
 from PIL import Image

 from transformers import AutoImageProcessor






class _lowerCamelCase:
       def __init__(      self,   lowerCamelCase,   lowerCamelCase=13,   lowerCamelCase=[30, 30],   lowerCamelCase=2,   lowerCamelCase=3,   lowerCamelCase=True,   lowerCamelCase=True,   lowerCamelCase=32,   lowerCamelCase=5,   lowerCamelCase=4,   lowerCamelCase=37,   lowerCamelCase="gelu",   lowerCamelCase=0.1,   lowerCamelCase=0.1,   lowerCamelCase=10,   lowerCamelCase=0.0_2,   lowerCamelCase=3,   lowerCamelCase=None,   lowerCamelCase=8,   lowerCamelCase=10,   ) ->     Union[str, Any]:




           """simple docstring"""

           _lowercase :							Optional[Any]   	=	parent
           _lowercase :							int   	=	batch_size
           _lowercase :							str   	=	image_size
           _lowercase :							Any   	=	patch_size
           _lowercase :							Optional[Any]   	=	num_channels
           _lowercase :							Union[str, Any]   	=	is_training
           _lowercase :							Dict   	=	use_labels
           _lowercase :							Optional[Any]   	=	hidden_size
           _lowercase :							Optional[int]   	=	num_hidden_layers
           _lowercase :							List[str]   	=	num_attention_heads
           _lowercase :							Optional[Any]   	=	intermediate_size
           _lowercase :							Tuple   	=	hidden_act
           _lowercase :							Union[str, Any]   	=	hidden_dropout_prob
           _lowercase :							str   	=	attention_probs_dropout_prob
           _lowercase :							int   	=	type_sequence_label_size
           _lowercase :							str   	=	initializer_range
           _lowercase :							Tuple   	=	num_labels
           _lowercase :							Any   	=	scope
           _lowercase :							Optional[Any]   	=	n_targets
           _lowercase :							List[Any]   	=	num_detection_tokens
           # we set the expected sequence length (which is used in several tests)
           # expected sequence length = num_patches + 1 (we add 1 for the [CLS] token) + num_detection_tokens
           _lowercase :							Tuple   	=	(image_size[1] // patch_size) * (image_size[0] // patch_size)
           _lowercase :							str   	=	num_patches + 1 + self.num_detection_tokens
       def     UpperCamelCase  (      self) ->     Union[str, Any]:




           """simple docstring"""

           _lowercase :							List[str]   	=	floats_tensor([self.batch_size, self.num_channels, self.image_size[0], self.image_size[1]])

           _lowercase :							str   	=	None
           if self.use_labels:
               # labels is a list of Dict (each Dict being the labels for a given example in the batch)
               _lowercase :							Optional[Any]   	=	[]
               for i in range(self.batch_size):
                   _lowercase :							Tuple   	=	{}
                   _lowercase :							Dict   	=	torch.randint(
                       high=self.num_labels,   size=(self.n_targets,),   device=lowerCamelCase)
                   _lowercase :							str   	=	torch.rand(self.n_targets,   4,   device=lowerCamelCase)
                   labels.append(lowerCamelCase)

           _lowercase :							Tuple   	=	self.get_config()

           return config, pixel_values, labels
       def     UpperCamelCase  (      self) ->     List[Any]:




           """simple docstring"""

           return YolosConfig(
               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,   num_detection_tokens=self.num_detection_tokens,   num_labels=self.num_labels,   )
       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase,   lowerCamelCase) ->     Tuple:




           """simple docstring"""

           _lowercase :							Dict   	=	YolosModel(config=lowerCamelCase)
           model.to(lowerCamelCase)
           model.eval()
           _lowercase :							Optional[int]   	=	model(lowerCamelCase)
           self.parent.assertEqual(
               result.last_hidden_state.shape,   (self.batch_size, self.expected_seq_len, self.hidden_size))
       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase,   lowerCamelCase) ->     Optional[Any]:




           """simple docstring"""

           _lowercase :							Optional[int]   	=	YolosForObjectDetection(lowerCamelCase)
           model.to(lowerCamelCase)
           model.eval()

           _lowercase :							List[Any]   	=	model(pixel_values=lowerCamelCase)
           _lowercase :							Union[str, Any]   	=	model(lowerCamelCase)

           self.parent.assertEqual(result.logits.shape,   (self.batch_size, self.num_detection_tokens, self.num_labels + 1))
           self.parent.assertEqual(result.pred_boxes.shape,   (self.batch_size, self.num_detection_tokens, 4))

           _lowercase :							Tuple   	=	model(pixel_values=lowerCamelCase,   labels=lowerCamelCase)

           self.parent.assertEqual(result.loss.shape,   ())
           self.parent.assertEqual(result.logits.shape,   (self.batch_size, self.num_detection_tokens, self.num_labels + 1))
           self.parent.assertEqual(result.pred_boxes.shape,   (self.batch_size, self.num_detection_tokens, 4))




       def     UpperCamelCase  (      self) ->     Any:




           """simple docstring"""

           _lowercase :							int   	=	self.prepare_config_and_inputs()
           _lowercase	,       _lowercase	,       _lowercase :							Dict   	=	config_and_inputs
           _lowercase :							Dict   	=	{'pixel_values': pixel_values}
           return config, inputs_dict






@require_torch
class _lowerCamelCase(		_a,				_a,				unittest.TestCase     ):
       lowercase_				:			int									=    (YolosModel, YolosForObjectDetection) if is_torch_available() else ()
       lowercase_				:			Optional[Any]									=    (
           {"""feature-extraction""": YolosModel, """object-detection""": YolosForObjectDetection} if is_torch_available() else {}
       )

       lowercase_				:			Tuple									=    False
       lowercase_				:			Optional[Any]									=    False
       lowercase_				:			Tuple									=    False
       lowercase_				:			Optional[Any]									=    False
       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase,   lowerCamelCase=False) ->     str:




           """simple docstring"""

           _lowercase :							List[Any]   	=	super()._prepare_for_class(lowerCamelCase,   lowerCamelCase,   return_labels=lowerCamelCase)

           if return_labels:
               if model_class.__name__ == "YolosForObjectDetection":
                   _lowercase :							Dict   	=	[]
                   for i in range(self.model_tester.batch_size):
                       _lowercase :							List[Any]   	=	{}
                       _lowercase :							str   	=	torch.ones(
                           size=(self.model_tester.n_targets,),   device=lowerCamelCase,   dtype=torch.long)
                       _lowercase :							List[str]   	=	torch.ones(
                           self.model_tester.n_targets,   4,   device=lowerCamelCase,   dtype=torch.float)
                       labels.append(lowerCamelCase)
                   _lowercase :							Optional[int]   	=	labels

           return inputs_dict
       def     UpperCamelCase  (      self) ->     Tuple:




           """simple docstring"""

           _lowercase :							str   	=	YolosModelTester(self)
           _lowercase :							int   	=	ConfigTester(self,   config_class=lowerCamelCase,   has_text_modality=lowerCamelCase,   hidden_size=37)
       def     UpperCamelCase  (      self) ->     int:




           """simple docstring"""

           self.config_tester.run_common_tests()
       def     UpperCamelCase  (      self) ->     int:




           """simple docstring"""

           pass
       def     UpperCamelCase  (      self) ->     List[str]:




           """simple docstring"""

           _lowercase	,       _lowercase :							Union[str, Any]   	=	self.model_tester.prepare_config_and_inputs_for_common()

           for model_class in self.all_model_classes:
               _lowercase :							Union[str, Any]   	=	model_class(lowerCamelCase)
               self.assertIsInstance(model.get_input_embeddings(),   (nn.Module))
               _lowercase :							Tuple   	=	model.get_output_embeddings()
               self.assertTrue(x is None or isinstance(lowerCamelCase,   nn.Linear))
       def     UpperCamelCase  (      self) ->     Tuple:




           """simple docstring"""

           _lowercase	,       _lowercase :							str   	=	self.model_tester.prepare_config_and_inputs_for_common()

           for model_class in self.all_model_classes:
               _lowercase :							Optional[int]   	=	model_class(lowerCamelCase)
               _lowercase :							Optional[Any]   	=	inspect.signature(model.forward)
               # signature.parameters is an OrderedDict => so arg_names order is deterministic
               _lowercase :							Union[str, Any]   	=	[*signature.parameters.keys()]

               _lowercase :							Any   	=	['pixel_values']
               self.assertListEqual(arg_names[:1],   lowerCamelCase)
       def     UpperCamelCase  (      self) ->     Any:




           """simple docstring"""

           _lowercase :							Optional[int]   	=	self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_model(*lowerCamelCase)
       def     UpperCamelCase  (      self) ->     int:




           """simple docstring"""

           _lowercase	,       _lowercase :							Tuple   	=	self.model_tester.prepare_config_and_inputs_for_common()
           _lowercase :							List[str]   	=	True

           # in YOLOS, the seq_len is different
           _lowercase :							Dict   	=	self.model_tester.expected_seq_len
           for model_class in self.all_model_classes:
               _lowercase :							Optional[Any]   	=	True
               _lowercase :							str   	=	False
               _lowercase :							Tuple   	=	True
               _lowercase :							Tuple   	=	model_class(lowerCamelCase)
               model.to(lowerCamelCase)
               model.eval()
               with torch.no_grad():
                   _lowercase :							int   	=	model(**self._prepare_for_class(lowerCamelCase,   lowerCamelCase))
               _lowercase :							Optional[int]   	=	outputs.attentions
               self.assertEqual(len(lowerCamelCase),   self.model_tester.num_hidden_layers)

               # check that output_attentions also work using config
               del inputs_dict["output_attentions"]
               _lowercase :							int   	=	True
               _lowercase :							Tuple   	=	model_class(lowerCamelCase)
               model.to(lowerCamelCase)
               model.eval()
               with torch.no_grad():
                   _lowercase :							Any   	=	model(**self._prepare_for_class(lowerCamelCase,   lowerCamelCase))
               _lowercase :							str   	=	outputs.attentions
               self.assertEqual(len(lowerCamelCase),   self.model_tester.num_hidden_layers)

               self.assertListEqual(
                   list(attentions[0].shape[-3:]),   [self.model_tester.num_attention_heads, seq_len, seq_len],   )
               _lowercase :							Optional[Any]   	=	len(lowerCamelCase)

               # Check attention is always last and order is fine
               _lowercase :							List[str]   	=	True
               _lowercase :							Union[str, Any]   	=	True
               _lowercase :							Any   	=	model_class(lowerCamelCase)
               model.to(lowerCamelCase)
               model.eval()
               with torch.no_grad():
                   _lowercase :							Dict   	=	model(**self._prepare_for_class(lowerCamelCase,   lowerCamelCase))

               _lowercase :							Dict   	=	1
               self.assertEqual(out_len + added_hidden_states,   len(lowerCamelCase))

               _lowercase :							Any   	=	outputs.attentions

               self.assertEqual(len(lowerCamelCase),   self.model_tester.num_hidden_layers)
               self.assertListEqual(
                   list(self_attentions[0].shape[-3:]),   [self.model_tester.num_attention_heads, seq_len, seq_len],   )
       def     UpperCamelCase  (      self) ->     Optional[int]:




           """simple docstring"""

           def check_hidden_states_output(lowerCamelCase,   lowerCamelCase,   lowerCamelCase):
               _lowercase :							Tuple   	=	model_class(lowerCamelCase)
               model.to(lowerCamelCase)
               model.eval()

               with torch.no_grad():
                   _lowercase :							Optional[Any]   	=	model(**self._prepare_for_class(lowerCamelCase,   lowerCamelCase))

               _lowercase :							int   	=	outputs.hidden_states

               _lowercase :							Dict   	=	getattr(
                   self.model_tester,   'expected_num_hidden_layers',   self.model_tester.num_hidden_layers + 1)
               self.assertEqual(len(lowerCamelCase),   lowerCamelCase)

               # YOLOS has a different seq_length
               _lowercase :							List[str]   	=	self.model_tester.expected_seq_len

               self.assertListEqual(
                   list(hidden_states[0].shape[-2:]),   [seq_length, self.model_tester.hidden_size],   )

           _lowercase	,       _lowercase :							Dict   	=	self.model_tester.prepare_config_and_inputs_for_common()

           for model_class in self.all_model_classes:
               _lowercase :							Any   	=	True
               check_hidden_states_output(lowerCamelCase,   lowerCamelCase,   lowerCamelCase)

               # check that output_hidden_states also work using config
               del inputs_dict["output_hidden_states"]
               _lowercase :							Union[str, Any]   	=	True

               check_hidden_states_output(lowerCamelCase,   lowerCamelCase,   lowerCamelCase)
       def     UpperCamelCase  (      self) ->     Dict:




           """simple docstring"""

           _lowercase :							Optional[int]   	=	self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_object_detection(*lowerCamelCase)




       @slow
       def     UpperCamelCase  (      self) ->     Dict:




           """simple docstring"""

           for model_name in YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               _lowercase :							Optional[Any]   	=	YolosModel.from_pretrained(lowerCamelCase)
               self.assertIsNotNone(lowerCamelCase)



def        UpperCamelCase_(   )					->		List[str]:
    _lowercase :							List[Any]   	=	Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'				)
    return image






@require_torch
@require_vision
class _lowerCamelCase(		unittest.TestCase     ):
       @cached_property
       def     UpperCamelCase  (      self) ->     Dict:




           """simple docstring"""

           return AutoImageProcessor.from_pretrained('hustvl/yolos-small') if is_vision_available() else None




       @slow
       def     UpperCamelCase  (      self) ->     int:




           """simple docstring"""

           _lowercase :							List[str]   	=	YolosForObjectDetection.from_pretrained('hustvl/yolos-small').to(lowerCamelCase)

           _lowercase :							int   	=	self.default_image_processor
           _lowercase :							List[Any]   	=	prepare_img()
           _lowercase :							str   	=	image_processor(images=lowerCamelCase,   return_tensors='pt').to(lowerCamelCase)

           # forward pass
           with torch.no_grad():
               _lowercase :							str   	=	model(inputs.pixel_values)

           # verify outputs
           _lowercase :							Optional[int]   	=	torch.Size((1, 1_00, 92))
           self.assertEqual(outputs.logits.shape,   lowerCamelCase)

           _lowercase :							Tuple   	=	torch.tensor(
               [[-2_4.0_2_4_8, -1_0.3_0_2_4, -1_4.8_2_9_0], [-4_2.0_3_9_2, -1_6.8_2_0_0, -2_7.4_3_3_4], [-2_7.2_7_4_3, -1_1.8_1_5_4, -1_8.7_1_4_8]],   device=lowerCamelCase,   )
           _lowercase :							Dict   	=	torch.tensor(
               [[0.2_5_5_9, 0.5_4_5_5, 0.4_7_0_6], [0.2_9_8_9, 0.7_2_7_9, 0.1_8_7_5], [0.7_7_3_2, 0.4_0_1_7, 0.4_4_6_2]],   device=lowerCamelCase)
           self.assertTrue(torch.allclose(outputs.logits[0, :3, :3],   lowerCamelCase,   atol=1E-4))
           self.assertTrue(torch.allclose(outputs.pred_boxes[0, :3, :3],   lowerCamelCase,   atol=1E-4))

           # verify postprocessing
           _lowercase :							str   	=	image_processor.post_process_object_detection(
               lowerCamelCase,   threshold=0.3,   target_sizes=[image.size[::-1]])[0]
           _lowercase :							Union[str, Any]   	=	torch.tensor([0.9_9_9_4, 0.9_7_9_0, 0.9_9_6_4, 0.9_9_7_2, 0.9_8_6_1]).to(lowerCamelCase)
           _lowercase :							Optional[Any]   	=	[75, 75, 17, 63, 17]
           _lowercase :							Union[str, Any]   	=	torch.tensor([3_3_5.0_6_0_9, 7_9.3_8_4_8, 3_7_5.4_2_1_6, 1_8_7.2_4_9_5]).to(lowerCamelCase)

           self.assertEqual(len(results['scores']),   5)
           self.assertTrue(torch.allclose(results['scores'],   lowerCamelCase,   atol=1E-4))
           self.assertSequenceEqual(results['labels'].tolist(),   lowerCamelCase)
           self.assertTrue(torch.allclose(results['boxes'][0, :],   lowerCamelCase))


