


# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch

import math
from dataclasses import dataclass
from typing import Optional, Tuple, Union

import torch

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput, randn_tensor
from .scheduling_utils import SchedulerMixin, SchedulerOutput






@dataclass
class _lowerCamelCase(		__UpperCAmelCase     ):
       lowercase_				:			torch.FloatTensor
       lowercase_				:			torch.FloatTensor






class _lowerCamelCase(		__UpperCAmelCase,				__UpperCAmelCase     ):
       lowercase_				:			int									=    1
       @register_to_config
       def __init__(      self,   lowerCamelCase = 20_00,   lowerCamelCase = 0.1_5,   lowerCamelCase = 0.0_1,   lowerCamelCase = 1_3_4_8.0,   lowerCamelCase = 1E-5,   lowerCamelCase = 1,   ) ->     int:




           """simple docstring"""

           _lowercase :							List[str]   	=	sigma_max

           # setable values
           _lowercase :							Tuple   	=	None

           self.set_sigmas(UpperCAmelCase_,   UpperCAmelCase_,   UpperCAmelCase_,   UpperCAmelCase_)
       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase = None) ->     Optional[Any]:




           """simple docstring"""

           return sample
       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase = None,   lowerCamelCase = None) ->     Optional[int]:




           """simple docstring"""

           _lowercase :							List[Any]   	=	sampling_eps if sampling_eps is not None else self.config.sampling_eps

           _lowercase :							Any   	=	torch.linspace(1,   UpperCAmelCase_,   UpperCAmelCase_,   device=UpperCAmelCase_)
       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase = None,   lowerCamelCase = None,   lowerCamelCase = None) ->     Dict:




           """simple docstring"""

           _lowercase :							Tuple   	=	sigma_min if sigma_min is not None else self.config.sigma_min
           _lowercase :							Tuple   	=	sigma_max if sigma_max is not None else self.config.sigma_max
           _lowercase :							str   	=	sampling_eps if sampling_eps is not None else self.config.sampling_eps
           if self.timesteps is None:
               self.set_timesteps(UpperCAmelCase_,   UpperCAmelCase_)

           _lowercase :							str   	=	sigma_min * (sigma_max / sigma_min) ** (self.timesteps / sampling_eps)
           _lowercase :							List[Any]   	=	torch.exp(torch.linspace(math.log(UpperCAmelCase_),   math.log(UpperCAmelCase_),   UpperCAmelCase_))
           _lowercase :							str   	=	torch.tensor([sigma_min * (sigma_max / sigma_min) ** t for t in self.timesteps])
       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase) ->     Any:




           """simple docstring"""

           return torch.where(
               timesteps == 0,   torch.zeros_like(t.to(timesteps.device)),   self.discrete_sigmas[timesteps - 1].to(timesteps.device),   )
       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase,   lowerCamelCase,   lowerCamelCase = None,   lowerCamelCase = True,   ) ->     List[Any]:




           """simple docstring"""

           if self.timesteps is None:
               raise ValueError(
                   '`self.timesteps` is not set, you need to run \'set_timesteps\' after creating the scheduler')

           _lowercase :							Tuple   	=	timestep * torch.ones(
               sample.shape[0],   device=sample.device)  # torch.repeat_interleave(timestep, sample.shape[0])
           _lowercase :							Optional[int]   	=	(timestep * (len(self.timesteps) - 1)).long()

           # mps requires indices to be in the same device, so we use cpu as is the default with cuda
           _lowercase :							Optional[int]   	=	timesteps.to(self.discrete_sigmas.device)

           _lowercase :							Union[str, Any]   	=	self.discrete_sigmas[timesteps].to(sample.device)
           _lowercase :							int   	=	self.get_adjacent_sigma(UpperCAmelCase_,   UpperCAmelCase_).to(sample.device)
           _lowercase :							str   	=	torch.zeros_like(UpperCAmelCase_)
           _lowercase :							Dict   	=	(sigma**2 - adjacent_sigma**2) ** 0.5

           # equation 6 in the paper: the model_output modeled by the network is grad_x log pt(x)
           # also equation 47 shows the analog from SDE models to ancestral sampling methods
           _lowercase :							str   	=	diffusion.flatten()
           while len(diffusion.shape) < len(sample.shape):
               _lowercase :							Dict   	=	diffusion.unsqueeze(-1)
           _lowercase :							int   	=	drift - diffusion**2 * model_output

           #  equation 6: sample noise for the diffusion term of
           _lowercase :							List[str]   	=	randn_tensor(
               sample.shape,   layout=sample.layout,   generator=UpperCAmelCase_,   device=sample.device,   dtype=sample.dtype)
           _lowercase :							Dict   	=	sample - drift  # subtract because `dt` is a small negative timestep
           # TODO is the variable diffusion the correct scaling term for the noise?
           _lowercase :							Union[str, Any]   	=	prev_sample_mean + diffusion * noise  # add impact of diffusion field g

           if not return_dict:
               return (prev_sample, prev_sample_mean)

           return SdeVeOutput(prev_sample=UpperCAmelCase_,   prev_sample_mean=UpperCAmelCase_)
       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase,   lowerCamelCase = None,   lowerCamelCase = True,   ) ->     int:




           """simple docstring"""

           if self.timesteps is None:
               raise ValueError(
                   '`self.timesteps` is not set, you need to run \'set_timesteps\' after creating the scheduler')

           # For small batch sizes, the paper "suggest replacing norm(z) with sqrt(d), where d is the dim. of z"
           # sample noise for correction
           _lowercase :							Union[str, Any]   	=	randn_tensor(sample.shape,   layout=sample.layout,   generator=UpperCAmelCase_).to(sample.device)

           # compute step size from the model_output, the noise, and the snr
           _lowercase :							Tuple   	=	torch.norm(model_output.reshape(model_output.shape[0],   -1),   dim=-1).mean()
           _lowercase :							str   	=	torch.norm(noise.reshape(noise.shape[0],   -1),   dim=-1).mean()
           _lowercase :							Any   	=	(self.config.snr * noise_norm / grad_norm) ** 2 * 2
           _lowercase :							List[Any]   	=	step_size * torch.ones(sample.shape[0]).to(sample.device)
           # self.repeat_scalar(step_size, sample.shape[0])

           # compute corrected sample: model_output term and noise term
           _lowercase :							Optional[int]   	=	step_size.flatten()
           while len(step_size.shape) < len(sample.shape):
               _lowercase :							Optional[int]   	=	step_size.unsqueeze(-1)
           _lowercase :							Any   	=	sample + step_size * model_output
           _lowercase :							Union[str, Any]   	=	prev_sample_mean + ((step_size * 2) ** 0.5) * noise

           if not return_dict:
               return (prev_sample,)

           return SchedulerOutput(prev_sample=UpperCAmelCase_)
       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase,   lowerCamelCase,   ) ->     Tuple:




           """simple docstring"""

           _lowercase :							str   	=	timesteps.to(original_samples.device)
           _lowercase :							int   	=	self.discrete_sigmas.to(original_samples.device)[timesteps]
           _lowercase :							Dict   	=	(
               noise * sigmas[:, None, None, None]
               if noise is not None
               else torch.randn_like(UpperCAmelCase_) * sigmas[:, None, None, None]
           )
           _lowercase :							Any   	=	noise + original_samples
           return noisy_samples




       def __len__(      self) ->     str:




           """simple docstring"""

           return self.config.num_train_timesteps






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))


