


import gc
import random
import unittest

import numpy as np
import torch
from transformers import XLMRobertaTokenizer

from diffusers import (
    AltDiffusionImgaImgPipeline,
    AutoencoderKL,
    PNDMScheduler,
    UNetaDConditionModel,
)
from diffusers.image_processor import VaeImageProcessor
from diffusers.pipelines.alt_diffusion.modeling_roberta_series import (
    RobertaSeriesConfig,
    RobertaSeriesModelWithTransformation,
)
from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu


enable_full_determinism()





class      __A     (unittest.TestCase):





							'''simple docstring'''

							def 		lowerCAmelCase       (				self							:      Dict       )					->Optional[int]:



														"""simple docstring"""



														super().tearDown()
														gc.collect()
														torch.cuda.empty_cache()



							@property
							def 		lowerCAmelCase       (				self							:      int       )					->Dict:



														"""simple docstring"""



														snake_case_           =		1
														snake_case_           =		3
														snake_case_           =		(32, 32)

														snake_case_           =		floats_tensor((batch_size, num_channels) + sizes		,       rng=random.Random(0       )       ).to(_UpperCAmelCase       )
														return image



							@property
							def 		lowerCAmelCase       (				self							:      Dict       )					->Dict:



														"""simple docstring"""



														torch.manual_seed(0       )
														snake_case_           =		UNetaDConditionModel(
														    block_out_channels=(32, 64)		,       layers_per_block=2		,       sample_size=32		,       in_channels=4		,       out_channels=4		,       down_block_types=("""DownBlock2D""", """CrossAttnDownBlock2D""")		,       up_block_types=("""CrossAttnUpBlock2D""", """UpBlock2D""")		,       cross_attention_dim=32		,       )
														return model



							@property
							def 		lowerCAmelCase       (				self							:      Any       )					->str:



														"""simple docstring"""



														torch.manual_seed(0       )
														snake_case_           =		AutoencoderKL(
														    block_out_channels=[32, 64]		,       in_channels=3		,       out_channels=3		,       down_block_types=["""DownEncoderBlock2D""", """DownEncoderBlock2D"""]		,       up_block_types=["""UpDecoderBlock2D""", """UpDecoderBlock2D"""]		,       latent_channels=4		,       )
														return model



							@property
							def 		lowerCAmelCase       (				self							:      Optional[int]       )					->Tuple:



														"""simple docstring"""



														torch.manual_seed(0       )
														snake_case_           =		RobertaSeriesConfig(
														    hidden_size=32		,       project_dim=32		,       intermediate_size=37		,       layer_norm_eps=1E-05		,       num_attention_heads=4		,       num_hidden_layers=5		,       pad_token_id=1		,       vocab_size=5_006		,       )
														return RobertaSeriesModelWithTransformation(_UpperCAmelCase       )



							@property
							def 		lowerCAmelCase       (				self							:      str       )					->str:



														"""simple docstring"""



														def extract(*UpperCAmelCase_							:      str		,       **UpperCAmelCase_							:      Optional[Any]       ):





																					class      __A     :





																												'''simple docstring'''

																												def __init__(				self							:      Optional[Any]       )					->str:



																																			"""simple docstring"""



																																			snake_case_           =		torch.ones([0]       )



																												def 		lowerCAmelCase       (				self							:      Union[str, Any]		,       UpperCAmelCase_							:      Optional[int]       )					->List[Any]:



																																			"""simple docstring"""



																																			self.pixel_values.to(_UpperCAmelCase       )
																																			return self


																					return Out()

														return extract



							def 		lowerCAmelCase       (				self							:      Optional[Any]       )					->List[Any]:



														"""simple docstring"""



														snake_case_           =		"""cpu"""  # ensure determinism for the device-dependent torch.Generator
														snake_case_           =		self.dummy_cond_unet
														snake_case_           =		PNDMScheduler(skip_prk_steps=_UpperCAmelCase       )
														snake_case_           =		self.dummy_vae
														snake_case_           =		self.dummy_text_encoder
														snake_case_           =		XLMRobertaTokenizer.from_pretrained("""hf-internal-testing/tiny-xlm-roberta"""       )
														snake_case_           =		77

														snake_case_           =		self.dummy_image.to(_UpperCAmelCase       )
														snake_case_           =		init_image / 2 + 0.5

														# make sure here that pndm scheduler skips prk
														snake_case_           =		AltDiffusionImgaImgPipeline(
														    unet=_UpperCAmelCase		,       scheduler=_UpperCAmelCase		,       vae=_UpperCAmelCase		,       text_encoder=_UpperCAmelCase		,       tokenizer=_UpperCAmelCase		,       safety_checker=_UpperCAmelCase		,       feature_extractor=self.dummy_extractor		,       )
														snake_case_           =		VaeImageProcessor(vae_scale_factor=alt_pipe.vae_scale_factor		,       do_normalize=_UpperCAmelCase       )
														snake_case_           =		alt_pipe.to(_UpperCAmelCase       )
														alt_pipe.set_progress_bar_config(disable=_UpperCAmelCase       )

														snake_case_           =		"""A painting of a squirrel eating a burger"""
														snake_case_           =		torch.Generator(device=_UpperCAmelCase       ).manual_seed(0       )
														snake_case_           =		alt_pipe(
														    [prompt]		,       generator=_UpperCAmelCase		,       guidance_scale=6.0		,       num_inference_steps=2		,       output_type="""np"""		,       image=_UpperCAmelCase		,       )

														snake_case_           =		output.images

														snake_case_           =		torch.Generator(device=_UpperCAmelCase       ).manual_seed(0       )
														snake_case_           =		alt_pipe(
														    [prompt]		,       generator=_UpperCAmelCase		,       guidance_scale=6.0		,       num_inference_steps=2		,       output_type="""np"""		,       image=_UpperCAmelCase		,       return_dict=_UpperCAmelCase		,       )[0]

														snake_case_           =		image[0, -3:, -3:, -1]
														snake_case_           =		image_from_tuple[0, -3:, -3:, -1]

														assert image.shape == (1, 32, 32, 3)
														snake_case_           =		np.array([0.4_427, 0.3_731, 0.4_249, 0.4_941, 0.4_546, 0.4_148, 0.4_193, 0.4_666, 0.4_499]       )

														assert np.abs(image_slice.flatten() - expected_slice       ).max() < 5E-3
														assert np.abs(image_from_tuple_slice.flatten() - expected_slice       ).max() < 5E-3



							@unittest.skipIf(torch_device != """cuda"""		,       """This test requires a GPU"""       )
							def 		lowerCAmelCase       (				self							:      List[str]       )					->str:



														"""simple docstring"""



														snake_case_           =		self.dummy_cond_unet
														snake_case_           =		PNDMScheduler(skip_prk_steps=_UpperCAmelCase       )
														snake_case_           =		self.dummy_vae
														snake_case_           =		self.dummy_text_encoder
														snake_case_           =		XLMRobertaTokenizer.from_pretrained("""hf-internal-testing/tiny-xlm-roberta"""       )
														snake_case_           =		77

														snake_case_           =		self.dummy_image.to(_UpperCAmelCase       )

														# put models in fp16
														snake_case_           =		unet.half()
														snake_case_           =		vae.half()
														snake_case_           =		bert.half()

														# make sure here that pndm scheduler skips prk
														snake_case_           =		AltDiffusionImgaImgPipeline(
														    unet=_UpperCAmelCase		,       scheduler=_UpperCAmelCase		,       vae=_UpperCAmelCase		,       text_encoder=_UpperCAmelCase		,       tokenizer=_UpperCAmelCase		,       safety_checker=_UpperCAmelCase		,       feature_extractor=self.dummy_extractor		,       )
														snake_case_           =		VaeImageProcessor(vae_scale_factor=alt_pipe.vae_scale_factor		,       do_normalize=_UpperCAmelCase       )
														snake_case_           =		alt_pipe.to(_UpperCAmelCase       )
														alt_pipe.set_progress_bar_config(disable=_UpperCAmelCase       )

														snake_case_           =		"""A painting of a squirrel eating a burger"""
														snake_case_           =		torch.manual_seed(0       )
														snake_case_           =		alt_pipe(
														    [prompt]		,       generator=_UpperCAmelCase		,       num_inference_steps=2		,       output_type="""np"""		,       image=_UpperCAmelCase		,       ).images

														assert image.shape == (1, 32, 32, 3)



							@unittest.skipIf(torch_device != """cuda"""		,       """This test requires a GPU"""       )
							def 		lowerCAmelCase       (				self							:      Union[str, Any]       )					->List[str]:



														"""simple docstring"""



														snake_case_           =		load_image(
														    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"""
														    """/img2img/sketch-mountains-input.jpg"""       )
														# resize to resolution that is divisible by 8 but not 16 or 32
														snake_case_           =		init_image.resize((760, 504)       )

														snake_case_           =		"""BAAI/AltDiffusion"""
														snake_case_           =		AltDiffusionImgaImgPipeline.from_pretrained(
														    _UpperCAmelCase		,       safety_checker=_UpperCAmelCase		,       )
														pipe.to(_UpperCAmelCase       )
														pipe.set_progress_bar_config(disable=_UpperCAmelCase       )
														pipe.enable_attention_slicing()

														snake_case_           =		"""A fantasy landscape, trending on artstation"""

														snake_case_           =		torch.manual_seed(0       )
														snake_case_           =		pipe(
														    prompt=_UpperCAmelCase		,       image=_UpperCAmelCase		,       strength=0.75		,       guidance_scale=7.5		,       generator=_UpperCAmelCase		,       output_type="""np"""		,       )
														snake_case_           =		output.images[0]

														snake_case_           =		image[255:258, 383:386, -1]

														assert image.shape == (504, 760, 3)
														snake_case_           =		np.array([0.9_358, 0.9_397, 0.9_599, 0.9_901, 1.0_000, 1.0_000, 0.9_882, 1.0_000, 1.0_000]       )

														assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1E-2





@slow
@require_torch_gpu
class      __A     (unittest.TestCase):





							'''simple docstring'''

							def 		lowerCAmelCase       (				self							:      Tuple       )					->List[str]:



														"""simple docstring"""



														super().tearDown()
														gc.collect()
														torch.cuda.empty_cache()



							def 		lowerCAmelCase       (				self							:      Optional[int]       )					->Optional[int]:



														"""simple docstring"""



														snake_case_           =		load_image(
														    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"""
														    """/img2img/sketch-mountains-input.jpg"""       )
														snake_case_           =		init_image.resize((768, 512)       )
														snake_case_           =		load_numpy(
														    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/img2img/fantasy_landscape_alt.npy"""       )

														snake_case_           =		"""BAAI/AltDiffusion"""
														snake_case_           =		AltDiffusionImgaImgPipeline.from_pretrained(
														    _UpperCAmelCase		,       safety_checker=_UpperCAmelCase		,       )
														pipe.to(_UpperCAmelCase       )
														pipe.set_progress_bar_config(disable=_UpperCAmelCase       )
														pipe.enable_attention_slicing()

														snake_case_           =		"""A fantasy landscape, trending on artstation"""

														snake_case_           =		torch.manual_seed(0       )
														snake_case_           =		pipe(
														    prompt=_UpperCAmelCase		,       image=_UpperCAmelCase		,       strength=0.75		,       guidance_scale=7.5		,       generator=_UpperCAmelCase		,       output_type="""np"""		,       )
														snake_case_           =		output.images[0]

														assert image.shape == (512, 768, 3)
														# img2img is flaky across GPUs even in fp32, so using MAE here
														assert np.abs(expected_image - image       ).max() < 1E-2







"""simple docstring"""
import unittest

from transformers import LiltConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
				import torch

				from transformers import (
				    LiltForQuestionAnswering,
				    LiltForSequenceClassification,
				    LiltForTokenClassification,
				    LiltModel,
				)
				from transformers.models.lilt.modeling_lilt import LILT_PRETRAINED_MODEL_ARCHIVE_LIST





class      __A     :





							'''simple docstring'''

							def __init__(				self							:      Optional[int]		,       UpperCAmelCase_							:      Optional[int]		,       UpperCAmelCase_							:      List[Any]=13		,       UpperCAmelCase_							:      Optional[int]=7		,       UpperCAmelCase_							:      List[str]=True		,       UpperCAmelCase_							:      int=True		,       UpperCAmelCase_							:      List[Any]=True		,       UpperCAmelCase_							:      Optional[int]=True		,       UpperCAmelCase_							:      List[str]=99		,       UpperCAmelCase_							:      Dict=24		,       UpperCAmelCase_							:      List[str]=2		,       UpperCAmelCase_							:      Optional[Any]=6		,       UpperCAmelCase_							:      int=37		,       UpperCAmelCase_							:      Optional[Any]="gelu"		,       UpperCAmelCase_							:      Optional[Any]=0.1		,       UpperCAmelCase_							:      List[Any]=0.1		,       UpperCAmelCase_							:      Any=512		,       UpperCAmelCase_							:      str=16		,       UpperCAmelCase_							:      List[str]=2		,       UpperCAmelCase_							:      Optional[int]=0.02		,       UpperCAmelCase_							:      Tuple=3		,       UpperCAmelCase_							:      Union[str, Any]=None		,       UpperCAmelCase_							:      Any=1_000		,       )					->Tuple:



														"""simple docstring"""



														snake_case_           =		parent
														snake_case_           =		batch_size
														snake_case_           =		seq_length
														snake_case_           =		is_training
														snake_case_           =		use_input_mask
														snake_case_           =		use_token_type_ids
														snake_case_           =		use_labels
														snake_case_           =		vocab_size
														snake_case_           =		hidden_size
														snake_case_           =		num_hidden_layers
														snake_case_           =		num_attention_heads
														snake_case_           =		intermediate_size
														snake_case_           =		hidden_act
														snake_case_           =		hidden_dropout_prob
														snake_case_           =		attention_probs_dropout_prob
														snake_case_           =		max_position_embeddings
														snake_case_           =		type_vocab_size
														snake_case_           =		type_sequence_label_size
														snake_case_           =		initializer_range
														snake_case_           =		num_labels
														snake_case_           =		scope
														snake_case_           =		range_bbox



							def 		lowerCAmelCase       (				self							:      Tuple       )					->int:



														"""simple docstring"""



														snake_case_           =		ids_tensor([self.batch_size, self.seq_length]		,       self.vocab_size       )

														snake_case_           =		ids_tensor([self.batch_size, self.seq_length, 4]		,       self.range_bbox       )
														# Ensure that bbox is legal
														for i in range(bbox.shape[0]       ):
																					for j in range(bbox.shape[1]       ):
																												if bbox[i, j, 3] < bbox[i, j, 1]:
																																			snake_case_           =		bbox[i, j, 3]
																																			snake_case_           =		bbox[i, j, 1]
																																			snake_case_           =		t
																												if bbox[i, j, 2] < bbox[i, j, 0]:
																																			snake_case_           =		bbox[i, j, 2]
																																			snake_case_           =		bbox[i, j, 0]
																																			snake_case_           =		t

														snake_case_           =		None
														if self.use_input_mask:
																					snake_case_           =		ids_tensor([self.batch_size, self.seq_length]		,       vocab_size=2       )

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

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

														snake_case_           =		self.get_config()

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



							def 		lowerCAmelCase       (				self							:      int       )					->Optional[int]:



														"""simple docstring"""



														return LiltConfig(
														    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		,       )



							def 		lowerCAmelCase       (				self							:      Any		,       UpperCAmelCase_							:      Union[str, Any]		,       UpperCAmelCase_							:      Any		,       UpperCAmelCase_							:      Dict		,       UpperCAmelCase_							:      int		,       UpperCAmelCase_							:      Union[str, Any]		,       UpperCAmelCase_							:      Optional[Any]		,       UpperCAmelCase_							:      Optional[int]		,       )					->str:



														"""simple docstring"""



														snake_case_           =		LiltModel(config=UpperCAmelCase_       )
														model.to(UpperCAmelCase_       )
														model.eval()
														snake_case_           =		model(UpperCAmelCase_		,       bbox=UpperCAmelCase_		,       attention_mask=UpperCAmelCase_		,       token_type_ids=UpperCAmelCase_       )
														snake_case_           =		model(UpperCAmelCase_		,       bbox=UpperCAmelCase_		,       token_type_ids=UpperCAmelCase_       )
														snake_case_           =		model(UpperCAmelCase_		,       bbox=UpperCAmelCase_       )

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



							def 		lowerCAmelCase       (				self							:      int		,       UpperCAmelCase_							:      str		,       UpperCAmelCase_							:      Any		,       UpperCAmelCase_							:      Tuple		,       UpperCAmelCase_							:      Union[str, Any]		,       UpperCAmelCase_							:      Optional[int]		,       UpperCAmelCase_							:      str		,       UpperCAmelCase_							:      List[Any]		,       )					->Dict:



														"""simple docstring"""



														snake_case_           =		self.num_labels
														snake_case_           =		LiltForTokenClassification(config=UpperCAmelCase_       )
														model.to(UpperCAmelCase_       )
														model.eval()
														snake_case_           =		model(
														    UpperCAmelCase_		,       bbox=UpperCAmelCase_		,       attention_mask=UpperCAmelCase_		,       token_type_ids=UpperCAmelCase_		,       labels=UpperCAmelCase_       )
														self.parent.assertEqual(result.logits.shape		,       (self.batch_size, self.seq_length, self.num_labels)       )



							def 		lowerCAmelCase       (				self							:      Any		,       UpperCAmelCase_							:      List[str]		,       UpperCAmelCase_							:      Dict		,       UpperCAmelCase_							:      str		,       UpperCAmelCase_							:      List[str]		,       UpperCAmelCase_							:      int		,       UpperCAmelCase_							:      List[Any]		,       UpperCAmelCase_							:      List[str]		,       )					->Dict:



														"""simple docstring"""



														snake_case_           =		LiltForQuestionAnswering(config=UpperCAmelCase_       )
														model.to(UpperCAmelCase_       )
														model.eval()
														snake_case_           =		model(
														    UpperCAmelCase_		,       bbox=UpperCAmelCase_		,       attention_mask=UpperCAmelCase_		,       token_type_ids=UpperCAmelCase_		,       start_positions=UpperCAmelCase_		,       end_positions=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 		lowerCAmelCase       (				self							:      int       )					->Optional[int]:



														"""simple docstring"""



														snake_case_           =		self.prepare_config_and_inputs()
														(
														    (
														    snake_case_
														)       ,						(
														    snake_case_
														)       ,						(
														    snake_case_
														)       ,						(
														    snake_case_
														)       ,						(
														    snake_case_
														)       ,						(
														    snake_case_
														)       ,						(
														    snake_case_
														)       ,						
														)           =		config_and_inputs
														snake_case_           =		{
														    """input_ids""": input_ids,
														    """bbox""": bbox,
														    """token_type_ids""": token_type_ids,
														    """attention_mask""": input_mask,
														}
														return config, inputs_dict





@require_torch
class      __A     (snake_case__						,		snake_case__						,		snake_case__						,		unittest.TestCase):





							'''simple docstring'''

							__lowercase:		Optional[int]							      =    (
							    (
							        LiltModel,
							        LiltForSequenceClassification,
							        LiltForTokenClassification,
							        LiltForQuestionAnswering,
							    )
							    if is_torch_available()
							    else ()
							)
							__lowercase:		Optional[Any]							      =    (
							    {
							        """feature-extraction""": LiltModel,
							        """question-answering""": LiltForQuestionAnswering,
							        """text-classification""": LiltForSequenceClassification,
							        """token-classification""": LiltForTokenClassification,
							        """zero-shot""": LiltForSequenceClassification,
							    }
							    if is_torch_available()
							    else {}
							)
							__lowercase:		Union[str, Any]							      =    False
							__lowercase:		List[str]							      =    False



							def 		lowerCAmelCase       (				self							:      str		,       UpperCAmelCase_							:      int		,       UpperCAmelCase_							:      List[str]		,       UpperCAmelCase_							:      Dict		,       UpperCAmelCase_							:      int		,       UpperCAmelCase_							:      Optional[int]       )					->Optional[int]:



														"""simple docstring"""



														return True



							def 		lowerCAmelCase       (				self							:      Dict       )					->Union[str, Any]:



														"""simple docstring"""



														snake_case_           =		LiltModelTester(self       )
														snake_case_           =		ConfigTester(self		,       config_class=UpperCAmelCase_		,       hidden_size=37       )



							def 		lowerCAmelCase       (				self							:      str       )					->List[Any]:



														"""simple docstring"""



														self.config_tester.run_common_tests()



							def 		lowerCAmelCase       (				self							:      List[str]       )					->int:



														"""simple docstring"""



														snake_case_           =		self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_model(*UpperCAmelCase_       )



							def 		lowerCAmelCase       (				self							:      Union[str, Any]       )					->List[str]:



														"""simple docstring"""



														snake_case_           =		self.model_tester.prepare_config_and_inputs()
														for type in ["absolute", "relative_key", "relative_key_query"]:
																					snake_case_           =		type
																					self.model_tester.create_and_check_model(*UpperCAmelCase_       )



							def 		lowerCAmelCase       (				self							:      List[Any]       )					->Dict:



														"""simple docstring"""



														snake_case_           =		self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_token_classification(*UpperCAmelCase_       )



							def 		lowerCAmelCase       (				self							:      Optional[Any]       )					->Dict:



														"""simple docstring"""



														snake_case_           =		self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_question_answering(*UpperCAmelCase_       )



							@slow
							def 		lowerCAmelCase       (				self							:      Union[str, Any]       )					->Optional[int]:



														"""simple docstring"""



														for model_name in LILT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																					snake_case_           =		LiltModel.from_pretrained(UpperCAmelCase_       )
																					self.assertIsNotNone(UpperCAmelCase_       )





@require_torch
@slow
class      __A     (unittest.TestCase):





							'''simple docstring'''

							def 		lowerCAmelCase       (				self							:      Optional[int]       )					->Dict:



														"""simple docstring"""



														snake_case_           =		LiltModel.from_pretrained("""SCUT-DLVCLab/lilt-roberta-en-base"""       ).to(UpperCAmelCase_       )

														snake_case_           =		torch.tensor([[1, 2]]		,       device=UpperCAmelCase_       )
														snake_case_           =		torch.tensor([[[1, 2, 3, 4], [5, 6, 7, 8]]]		,       device=UpperCAmelCase_       )

														# forward pass
														with torch.no_grad():
																					snake_case_           =		model(input_ids=UpperCAmelCase_		,       bbox=UpperCAmelCase_       )

														snake_case_           =		torch.Size([1, 2, 768]       )
														snake_case_           =		torch.tensor(
														    [[-0.0_653, 0.0_950, -0.0_061], [-0.0_545, 0.0_926, -0.0_324]]		,       device=UpperCAmelCase_		,       )

														self.assertTrue(outputs.last_hidden_state.shape		,       UpperCAmelCase_       )
														self.assertTrue(torch.allclose(outputs.last_hidden_state[0, :, :3]		,       UpperCAmelCase_		,       atol=1E-3       )       )



