
'''simple docstring'''
import gc
import random
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

import diffusers
from diffusers import (
    AutoencoderKL,
    EulerDiscreteScheduler,
    StableDiffusionLatentUpscalePipeline,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.schedulers import KarrasDiffusionSchedulers
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

from ..pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS
from ..test_pipelines_common import PipelineKarrasSchedulerTesterMixin, PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()






def  __SCREAMING_SNAKE_CASE				(  _SCREAMING_SNAKE_CASE				):
							_snake_case       =  [tensor.shape for tensor in tensor_list]
							return all(shape == shapes[0] for shape in shapes[1:]				)


class       _lowerCAmelCase   (   __snake_case					,							__snake_case					,							__snake_case					,							unittest.TestCase				):







							'''simple docstring'''

							lowerCAmelCase_ 						=						StableDiffusionLatentUpscalePipeline
							lowerCAmelCase_ 						=						TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {
							    "height",
							    "width",
							    "cross_attention_kwargs",
							    "negative_prompt_embeds",
							    "prompt_embeds",
							}
							lowerCAmelCase_ 						=						PipelineTesterMixin.required_optional_params - {"num_images_per_prompt"}
							lowerCAmelCase_ 						=						TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
							lowerCAmelCase_ 						=						frozenset(
							    []				)  # TO-DO: update image_params once pipeline is refactored with VaeImageProcessor.preprocess
							lowerCAmelCase_ 						=						frozenset([]				)

							lowerCAmelCase_ 						=						True

							@property
							def 	lowercase							(self  )					->       List[str]:
														_snake_case       =  1
														_snake_case       =  4
														_snake_case       =  (16, 16)

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

							def 	lowercase							(self  )					->       Union[str, Any]:
														torch.manual_seed(0  )
														_snake_case       =  UNetaDConditionModel(
														    act_fn="""gelu"""  ,  attention_head_dim=8  ,  norm_num_groups=UpperCAmelCase  ,  block_out_channels=[32, 32, 64, 64]  ,  time_cond_proj_dim=160  ,  conv_in_kernel=1  ,  conv_out_kernel=1  ,  cross_attention_dim=32  ,  down_block_types=(
														        """KDownBlock2D""",
														        """KCrossAttnDownBlock2D""",
														        """KCrossAttnDownBlock2D""",
														        """KCrossAttnDownBlock2D""",
														    )  ,  in_channels=8  ,  mid_block_type=UpperCAmelCase  ,  only_cross_attention=UpperCAmelCase  ,  out_channels=5  ,  resnet_time_scale_shift="""scale_shift"""  ,  time_embedding_type="""fourier"""  ,  timestep_post_act="""gelu"""  ,  up_block_types=("""KCrossAttnUpBlock2D""", """KCrossAttnUpBlock2D""", """KCrossAttnUpBlock2D""", """KUpBlock2D""")  ,  )
														_snake_case       =  AutoencoderKL(
														    block_out_channels=[32, 32, 64, 64]  ,  in_channels=3  ,  out_channels=3  ,  down_block_types=[
														        """DownEncoderBlock2D""",
														        """DownEncoderBlock2D""",
														        """DownEncoderBlock2D""",
														        """DownEncoderBlock2D""",
														    ]  ,  up_block_types=["""UpDecoderBlock2D""", """UpDecoderBlock2D""", """UpDecoderBlock2D""", """UpDecoderBlock2D"""]  ,  latent_channels=4  ,  )
														_snake_case       =  EulerDiscreteScheduler(prediction_type="""sample"""  )
														_snake_case       =  CLIPTextConfig(
														    bos_token_id=0  ,  eos_token_id=2  ,  hidden_size=32  ,  intermediate_size=37  ,  layer_norm_eps=1e-0_5  ,  num_attention_heads=4  ,  num_hidden_layers=5  ,  pad_token_id=1  ,  vocab_size=1000  ,  hidden_act="""quick_gelu"""  ,  projection_dim=512  ,  )
														_snake_case       =  CLIPTextModel(UpperCAmelCase  )
														_snake_case       =  CLIPTokenizer.from_pretrained("""hf-internal-testing/tiny-random-clip"""  )

														_snake_case       =  {
														    """unet""": model.eval(),
														    """vae""": vae.eval(),
														    """scheduler""": scheduler,
														    """text_encoder""": text_encoder,
														    """tokenizer""": tokenizer,
														}

														return components

							def 	lowercase							(self  ,  UpperCAmelCase  ,  UpperCAmelCase=0  )					->       Optional[int]:
														if str(UpperCAmelCase  ).startswith("""mps"""  ):
																					_snake_case       =  torch.manual_seed(UpperCAmelCase  )
														else:
																					_snake_case       =  torch.Generator(device=UpperCAmelCase  ).manual_seed(UpperCAmelCase  )
														_snake_case       =  {
														    """prompt""": """A painting of a squirrel eating a burger""",
														    """image""": self.dummy_image.cpu(),
														    """generator""": generator,
														    """num_inference_steps""": 2,
														    """output_type""": """numpy""",
														}
														return inputs

							def 	lowercase							(self  )					->       str:
														_snake_case       =  """cpu"""

														_snake_case       =  self.get_dummy_components()
														_snake_case       =  self.pipeline_class(**UpperCAmelCase  )
														pipe.to(UpperCAmelCase  )
														pipe.set_progress_bar_config(disable=UpperCAmelCase  )

														_snake_case       =  self.get_dummy_inputs(UpperCAmelCase  )
														_snake_case       =  pipe(**UpperCAmelCase  ).images
														_snake_case       =  image[0, -3:, -3:, -1]

														self.assertEqual(image.shape  ,  (1, 256, 256, 3)  )
														_snake_case       =  np.array(
														    [0.4722_2412, 0.4192_1633, 0.4471_7434, 0.4687_4192, 0.4258_8258, 0.4615_0726, 0.467_7534, 0.4558_3832, 0.4857_9055]  )
														_snake_case       =  np.abs(image_slice.flatten() - expected_slice  ).max()
														self.assertLessEqual(UpperCAmelCase  ,  1e-3  )

							def 	lowercase							(self  )					->       Any:
														super().test_attention_slicing_forward_pass(expected_max_diff=7e-3  )

							def 	lowercase							(self  )					->       Tuple:
														super().test_cpu_offload_forward_pass(expected_max_diff=3e-3  )

							def 	lowercase							(self  )					->       Optional[Any]:
														super().test_dict_tuple_outputs_equivalent(expected_max_difference=3e-3  )

							def 	lowercase							(self  )					->       List[Any]:
														super().test_inference_batch_single_identical(expected_max_diff=7e-3  )

							def 	lowercase							(self  )					->       List[Any]:
														super().test_pt_np_pil_outputs_equivalent(expected_max_diff=3e-3  )

							def 	lowercase							(self  )					->       int:
														super().test_save_load_local(expected_max_difference=3e-3  )

							def 	lowercase							(self  )					->       Tuple:
														super().test_save_load_optional_components(expected_max_difference=3e-3  )





							def 	lowercase							(self  )					->       List[str]:
														_snake_case       =  [
														    """DDIMScheduler""",
														    """DDPMScheduler""",
														    """PNDMScheduler""",
														    """HeunDiscreteScheduler""",
														    """EulerAncestralDiscreteScheduler""",
														    """KDPM2DiscreteScheduler""",
														    """KDPM2AncestralDiscreteScheduler""",
														    """DPMSolverSDEScheduler""",
														]
														_snake_case       =  self.get_dummy_components()
														_snake_case       =  self.pipeline_class(**UpperCAmelCase  )

														# make sure that PNDM does not need warm-up
														pipe.scheduler.register_to_config(skip_prk_steps=UpperCAmelCase  )

														pipe.to(UpperCAmelCase  )
														pipe.set_progress_bar_config(disable=UpperCAmelCase  )
														_snake_case       =  self.get_dummy_inputs(UpperCAmelCase  )
														_snake_case       =  2

														_snake_case       =  []
														for scheduler_enum in KarrasDiffusionSchedulers:
																					if scheduler_enum.name in skip_schedulers:
																												# no sigma schedulers are not supported
																												# no schedulers
																												continue

																					_snake_case       =  getattr(UpperCAmelCase  ,  scheduler_enum.name  )
																					_snake_case       =  scheduler_cls.from_config(pipe.scheduler.config  )
																					_snake_case       =  pipe(**UpperCAmelCase  )[0]
																					outputs.append(UpperCAmelCase  )

														assert check_same_shape(UpperCAmelCase  )


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







							'''simple docstring'''

							def 	lowercase							(self  )					->       Optional[int]:
														super().tearDown()
														gc.collect()
														torch.cuda.empty_cache()

							def 	lowercase							(self  )					->       Any:
														_snake_case       =  torch.manual_seed(33  )

														_snake_case       =  StableDiffusionPipeline.from_pretrained("""CompVis/stable-diffusion-v1-4"""  ,  torch_dtype=torch.floataa  )
														pipe.to("""cuda"""  )

														_snake_case       =  StableDiffusionLatentUpscalePipeline.from_pretrained(
														    """stabilityai/sd-x2-latent-upscaler"""  ,  torch_dtype=torch.floataa  )
														upscaler.to("""cuda"""  )

														_snake_case       =  """a photo of an astronaut high resolution, unreal engine, ultra realistic"""

														_snake_case       =  pipe(UpperCAmelCase  ,  generator=UpperCAmelCase  ,  output_type="""latent"""  ).images

														_snake_case       =  upscaler(
														    prompt=UpperCAmelCase  ,  image=UpperCAmelCase  ,  num_inference_steps=20  ,  guidance_scale=0  ,  generator=UpperCAmelCase  ,  output_type="""np"""  ,  ).images[0]

														_snake_case       =  load_numpy(
														    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/latent-upscaler/astronaut_1024.npy"""  )
														assert np.abs((expected_image - image).mean()  ) < 5e-2





							def 	lowercase							(self  )					->       int:
														_snake_case       =  torch.manual_seed(33  )

														_snake_case       =  StableDiffusionLatentUpscalePipeline.from_pretrained(
														    """stabilityai/sd-x2-latent-upscaler"""  ,  torch_dtype=torch.floataa  )
														upscaler.to("""cuda"""  )

														_snake_case       =  """the temple of fire by Ross Tran and Gerardo Dottori, oil on canvas"""

														_snake_case       =  load_image(
														    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/latent-upscaler/fire_temple_512.png"""  )

														_snake_case       =  upscaler(
														    prompt=UpperCAmelCase  ,  image=UpperCAmelCase  ,  num_inference_steps=20  ,  guidance_scale=0  ,  generator=UpperCAmelCase  ,  output_type="""np"""  ,  ).images[0]

														_snake_case       =  load_numpy(
														    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/latent-upscaler/fire_temple_1024.npy"""  )
														assert np.abs((expected_image - image).max()  ) < 5e-2

'''simple docstring'''
import unittest

from transformers import DebertaConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

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 (
				    DebertaForMaskedLM,
				    DebertaForQuestionAnswering,
				    DebertaForSequenceClassification,
				    DebertaForTokenClassification,
				    DebertaModel,
				)
				from transformers.models.deberta.modeling_deberta import DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST


class       _lowerCAmelCase   (   __snake_case				):







							'''simple docstring'''

							def __init__(self  ,  UpperCAmelCase  ,  UpperCAmelCase=13  ,  UpperCAmelCase=7  ,  UpperCAmelCase=True  ,  UpperCAmelCase=True  ,  UpperCAmelCase=True  ,  UpperCAmelCase=True  ,  UpperCAmelCase=99  ,  UpperCAmelCase=32  ,  UpperCAmelCase=5  ,  UpperCAmelCase=4  ,  UpperCAmelCase=37  ,  UpperCAmelCase="gelu"  ,  UpperCAmelCase=0.1  ,  UpperCAmelCase=0.1  ,  UpperCAmelCase=512  ,  UpperCAmelCase=16  ,  UpperCAmelCase=2  ,  UpperCAmelCase=0.02  ,  UpperCAmelCase=False  ,  UpperCAmelCase=True  ,  UpperCAmelCase="None"  ,  UpperCAmelCase=3  ,  UpperCAmelCase=4  ,  UpperCAmelCase=None  ,  )					->       Optional[Any]:
														_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       =  num_choices
														_snake_case       =  relative_attention
														_snake_case       =  position_biased_input
														_snake_case       =  pos_att_type
														_snake_case       =  scope

							def 	lowercase							(self  )					->       List[Any]:
														_snake_case       =  ids_tensor([self.batch_size, self.seq_length]  ,  self.vocab_size  )

														_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
														_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       =  ids_tensor([self.batch_size]  ,  self.num_choices  )

														_snake_case       =  self.get_config()

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

							def 	lowercase							(self  )					->       int:
														return DebertaConfig(
														    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  ,  relative_attention=self.relative_attention  ,  position_biased_input=self.position_biased_input  ,  pos_att_type=self.pos_att_type  ,  )

							def 	lowercase							(self  )					->       int:
														_snake_case       =  self.get_config()
														_snake_case       =  300
														return config

							def 	lowercase							(self  ,  UpperCAmelCase  )					->       Dict:
														self.parent.assertListEqual(list(result.loss.size()  )  ,  []  )

							def 	lowercase							(self  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  )					->       Optional[Any]:
														_snake_case       =  DebertaModel(config=UpperCAmelCase  )
														model.to(UpperCAmelCase  )
														model.eval()
														_snake_case       =  model(UpperCAmelCase  ,  attention_mask=UpperCAmelCase  ,  token_type_ids=UpperCAmelCase  )[0]
														_snake_case       =  model(UpperCAmelCase  ,  token_type_ids=UpperCAmelCase  )[0]
														_snake_case       =  model(UpperCAmelCase  )[0]

														self.parent.assertListEqual(list(sequence_output.size()  )  ,  [self.batch_size, self.seq_length, self.hidden_size]  )

							def 	lowercase							(self  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  )					->       str:
														_snake_case       =  DebertaForMaskedLM(config=UpperCAmelCase  )
														model.to(UpperCAmelCase  )
														model.eval()
														_snake_case       =  model(UpperCAmelCase  ,  attention_mask=UpperCAmelCase  ,  token_type_ids=UpperCAmelCase  ,  labels=UpperCAmelCase  )

														self.parent.assertEqual(result.logits.shape  ,  (self.batch_size, self.seq_length, self.vocab_size)  )

							def 	lowercase							(self  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  )					->       List[str]:
														_snake_case       =  self.num_labels
														_snake_case       =  DebertaForSequenceClassification(UpperCAmelCase  )
														model.to(UpperCAmelCase  )
														model.eval()
														_snake_case       =  model(UpperCAmelCase  ,  attention_mask=UpperCAmelCase  ,  token_type_ids=UpperCAmelCase  ,  labels=UpperCAmelCase  )
														self.parent.assertListEqual(list(result.logits.size()  )  ,  [self.batch_size, self.num_labels]  )
														self.check_loss_output(UpperCAmelCase  )

							def 	lowercase							(self  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  )					->       Any:
														_snake_case       =  self.num_labels
														_snake_case       =  DebertaForTokenClassification(config=UpperCAmelCase  )
														model.to(UpperCAmelCase  )
														model.eval()
														_snake_case       =  model(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 	lowercase							(self  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  )					->       Any:
														_snake_case       =  DebertaForQuestionAnswering(config=UpperCAmelCase  )
														model.to(UpperCAmelCase  )
														model.eval()
														_snake_case       =  model(
														    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 	lowercase							(self  )					->       Tuple:
														_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, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
														return config, inputs_dict


@require_torch
class       _lowerCAmelCase   (   __snake_case					,							__snake_case					,							unittest.TestCase				):







							'''simple docstring'''

							lowerCAmelCase_ 						=						(
							    (
							        DebertaModel,
							        DebertaForMaskedLM,
							        DebertaForSequenceClassification,
							        DebertaForTokenClassification,
							        DebertaForQuestionAnswering,
							    )
							    if is_torch_available()
							    else ()
							)
							lowerCAmelCase_ 						=						(
							    {
							        "feature-extraction": DebertaModel,
							        "fill-mask": DebertaForMaskedLM,
							        "question-answering": DebertaForQuestionAnswering,
							        "text-classification": DebertaForSequenceClassification,
							        "token-classification": DebertaForTokenClassification,
							        "zero-shot": DebertaForSequenceClassification,
							    }
							    if is_torch_available()
							    else {}
							)

							lowerCAmelCase_ 						=						True
							lowerCAmelCase_ 						=						False
							lowerCAmelCase_ 						=						False
							lowerCAmelCase_ 						=						False
							lowerCAmelCase_ 						=						False

							def 	lowercase							(self  )					->       Any:
														_snake_case       =  DebertaModelTester(self  )
														_snake_case       =  ConfigTester(self  ,  config_class=UpperCAmelCase  ,  hidden_size=37  )

							def 	lowercase							(self  )					->       List[str]:
														self.config_tester.run_common_tests()

							def 	lowercase							(self  )					->       Tuple:
														_snake_case       =  self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_deberta_model(*UpperCAmelCase  )

							def 	lowercase							(self  )					->       str:
														_snake_case       =  self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_deberta_for_sequence_classification(*UpperCAmelCase  )

							def 	lowercase							(self  )					->       int:
														_snake_case       =  self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_deberta_for_masked_lm(*UpperCAmelCase  )

							def 	lowercase							(self  )					->       Any:
														_snake_case       =  self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_deberta_for_question_answering(*UpperCAmelCase  )

							def 	lowercase							(self  )					->       str:
														_snake_case       =  self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_deberta_for_token_classification(*UpperCAmelCase  )





							@slow
							def 	lowercase							(self  )					->       Tuple:
														for model_name in DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																					_snake_case       =  DebertaModel.from_pretrained(UpperCAmelCase  )
																					self.assertIsNotNone(UpperCAmelCase  )


@require_torch
@require_sentencepiece
@require_tokenizers
class       _lowerCAmelCase   (   unittest.TestCase				):







							'''simple docstring'''

							@unittest.skip(reason="""Model not available yet"""  )
							def 	lowercase							(self  )					->       Any:
														pass





							@slow
							def 	lowercase							(self  )					->       Dict:
														_snake_case       =  DebertaModel.from_pretrained("""microsoft/deberta-base"""  )

														_snake_case       =  torch.tensor([[0, 31414, 232, 328, 740, 1140, 12695, 69, 46078, 1588, 2]]  )
														_snake_case       =  torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]  )
														with torch.no_grad():
																					_snake_case       =  model(UpperCAmelCase  ,  attention_mask=UpperCAmelCase  )[0]
														# compare the actual values for a slice.
														_snake_case       =  torch.tensor(
														    [[[-0.5986, -0.8055, -0.8462], [1.4484, -0.9348, -0.8059], [0.3123, 0.0032, -1.4131]]]  )
														self.assertTrue(torch.allclose(output[:, 1:4, 1:4]  ,  UpperCAmelCase  ,  atol=1e-4  )  ,  f"""{output[:, 1:4, 1:4]}"""  )