





import argparse
import json
from pathlib import Path

import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image

from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel
from transformers.utils import logging


logging.set_verbosity_info()
_lowercase		:  List[str]			       =logging.get_logger(__name__)


def 		_SCREAMING_SNAKE_CASE     ( lowerCAmelCase__							,lowerCAmelCase__=False						):
		lowerCamelCase_	:     int 						=      []
		for i in range(config.num_hidden_layers						):
				# encoder layers: output projection, 2 feedforward neural networks and 2 layernorms
				rename_keys.append((F"blocks.{i}.norm1.weight", F"vit.encoder.layer.{i}.layernorm_before.weight")						)
				rename_keys.append((F"blocks.{i}.norm1.bias", F"vit.encoder.layer.{i}.layernorm_before.bias")						)
				rename_keys.append((F"blocks.{i}.attn.proj.weight", F"vit.encoder.layer.{i}.attention.output.dense.weight")						)
				rename_keys.append((F"blocks.{i}.attn.proj.bias", F"vit.encoder.layer.{i}.attention.output.dense.bias")						)
				rename_keys.append((F"blocks.{i}.norm2.weight", F"vit.encoder.layer.{i}.layernorm_after.weight")						)
				rename_keys.append((F"blocks.{i}.norm2.bias", F"vit.encoder.layer.{i}.layernorm_after.bias")						)
				rename_keys.append((F"blocks.{i}.mlp.fc1.weight", F"vit.encoder.layer.{i}.intermediate.dense.weight")						)
				rename_keys.append((F"blocks.{i}.mlp.fc1.bias", F"vit.encoder.layer.{i}.intermediate.dense.bias")						)
				rename_keys.append((F"blocks.{i}.mlp.fc2.weight", F"vit.encoder.layer.{i}.output.dense.weight")						)
				rename_keys.append((F"blocks.{i}.mlp.fc2.bias", F"vit.encoder.layer.{i}.output.dense.bias")						)

		# projection layer + position embeddings
		rename_keys.extend(
		    [
		        ('cls_token', 'vit.embeddings.cls_token'),
		        ('patch_embed.proj.weight', 'vit.embeddings.patch_embeddings.projection.weight'),
		        ('patch_embed.proj.bias', 'vit.embeddings.patch_embeddings.projection.bias'),
		        ('pos_embed', 'vit.embeddings.position_embeddings'),
		    ]						)

		if base_model:
				# layernorm + pooler
				rename_keys.extend(
				    [
				        ('norm.weight', 'layernorm.weight'),
				        ('norm.bias', 'layernorm.bias'),
				    ]						)

				# if just the base model, we should remove "vit" from all keys that start with "vit"
				lowerCamelCase_	:     Union[str, Any] 						=      [(pair[0], pair[1][4:]) if pair[1].startswith('vit'						) else pair for pair in rename_keys]
		else:
				# layernorm + classification head
				rename_keys.extend(
				    [
				        ('norm.weight', 'vit.layernorm.weight'),
				        ('norm.bias', 'vit.layernorm.bias'),
				        ('head.weight', 'classifier.weight'),
				        ('head.bias', 'classifier.bias'),
				    ]						)

		return rename_keys


def 		_SCREAMING_SNAKE_CASE     ( lowerCAmelCase__							,lowerCAmelCase__							,lowerCAmelCase__=False						):
		for i in range(config.num_hidden_layers						):
				if base_model:
						lowerCamelCase_	:     Tuple 						=      ''
				else:
						lowerCamelCase_	:     List[str] 						=      'vit.'
				# read in weights + bias of input projection layer (in timm, this is a single matrix + bias)
				lowerCamelCase_	:     List[str] 						=      state_dict.pop(F"blocks.{i}.attn.qkv.weight"						)
				lowerCamelCase_	:     str 						=      state_dict.pop(F"blocks.{i}.attn.qkv.bias"						)
				# next, add query, keys and values (in that order) to the state dict
				lowerCamelCase_	:     Tuple 						=      in_proj_weight[
				    : config.hidden_size, :
				]
				lowerCamelCase_	:     Tuple 						=      in_proj_bias[: config.hidden_size]
				lowerCamelCase_	:     Dict 						=      in_proj_weight[
				    config.hidden_size : config.hidden_size * 2, :
				]
				lowerCamelCase_	:     Optional[int] 						=      in_proj_bias[
				    config.hidden_size : config.hidden_size * 2
				]
				lowerCamelCase_	:     Optional[Any] 						=      in_proj_weight[
				    -config.hidden_size :, :
				]
				lowerCamelCase_	:     Optional[Any] 						=      in_proj_bias[-config.hidden_size :]


def 		_SCREAMING_SNAKE_CASE     ( lowerCAmelCase__						):
		lowerCamelCase_	:     int 						=      ['head.weight', 'head.bias']
		for k in ignore_keys:
				state_dict.pop(lowerCAmelCase__							,lowerCAmelCase__						)


def 		_SCREAMING_SNAKE_CASE     ( lowerCAmelCase__							,lowerCAmelCase__							,lowerCAmelCase__						):
		lowerCamelCase_	:     List[Any] 						=      dct.pop(lowerCAmelCase__						)
		lowerCamelCase_	:     List[str] 						=      val


def 		_SCREAMING_SNAKE_CASE     ( ):
		lowerCamelCase_	:     List[str] 						=      'http://images.cocodataset.org/val2017/000000039769.jpg'
		lowerCamelCase_	:     str 						=      Image.open(requests.get(lowerCAmelCase__							,stream=lowerCAmelCase__						).raw						)
		return im


@torch.no_grad()
def 		_SCREAMING_SNAKE_CASE     ( lowerCAmelCase__							,lowerCAmelCase__							,lowerCAmelCase__=True						):
		lowerCamelCase_	:     List[str] 						=      ViTConfig()
		# patch_size
		if model_name[-1] == "8":
				lowerCamelCase_	:     List[str] 						=      8
		# set labels if required
		if not base_model:
				lowerCamelCase_	:     str 						=      10_00
				lowerCamelCase_	:     str 						=      'huggingface/label-files'
				lowerCamelCase_	:     Tuple 						=      'imagenet-1k-id2label.json'
				lowerCamelCase_	:     Optional[Any] 						=      json.load(open(hf_hub_download(lowerCAmelCase__							,lowerCAmelCase__							,repo_type='dataset'						)							,'r'						)						)
				lowerCamelCase_	:     int 						=      {int(lowerCAmelCase__						): v for k, v in idalabel.items()}
				lowerCamelCase_	:     Any 						=      idalabel
				lowerCamelCase_	:     Any 						=      {v: k for k, v in idalabel.items()}
		# size of the architecture
		if model_name in ["dino_vits8", "dino_vits16"]:
				lowerCamelCase_	:     Optional[Any] 						=      3_84
				lowerCamelCase_	:     Optional[Any] 						=      15_36
				lowerCamelCase_	:     Union[str, Any] 						=      12
				lowerCamelCase_	:     Optional[Any] 						=      6

		# load original model from torch hub
		lowerCamelCase_	:     Any 						=      torch.hub.load('facebookresearch/dino:main'							,lowerCAmelCase__						)
		original_model.eval()

		# load state_dict of original model, remove and rename some keys
		lowerCamelCase_	:     List[Any] 						=      original_model.state_dict()
		if base_model:
				remove_classification_head_(lowerCAmelCase__						)
		lowerCamelCase_	:     Union[str, Any] 						=      create_rename_keys(lowerCAmelCase__							,base_model=lowerCAmelCase__						)
		for src, dest in rename_keys:
				rename_key(lowerCAmelCase__							,lowerCAmelCase__							,lowerCAmelCase__						)
		read_in_q_k_v(lowerCAmelCase__							,lowerCAmelCase__							,lowerCAmelCase__						)

		# load HuggingFace model
		if base_model:
				lowerCamelCase_	:     Any 						=      ViTModel(lowerCAmelCase__							,add_pooling_layer=lowerCAmelCase__						).eval()
		else:
				lowerCamelCase_	:     List[str] 						=      ViTForImageClassification(lowerCAmelCase__						).eval()
		model.load_state_dict(lowerCAmelCase__						)

		# Check outputs on an image, prepared by ViTImageProcessor
		lowerCamelCase_	:     str 						=      ViTImageProcessor()
		lowerCamelCase_	:     Optional[int] 						=      image_processor(images=prepare_img()							,return_tensors='pt'						)
		lowerCamelCase_	:     List[str] 						=      encoding['pixel_values']
		lowerCamelCase_	:     Any 						=      model(lowerCAmelCase__						)

		if base_model:
				lowerCamelCase_	:     str 						=      original_model(lowerCAmelCase__						)
				assert torch.allclose(lowerCAmelCase__							,outputs.last_hidden_state[:, 0, :]							,atol=1e-1						)
		else:
				lowerCamelCase_	:     str 						=      original_model(lowerCAmelCase__						)
				assert logits.shape == outputs.logits.shape
				assert torch.allclose(lowerCAmelCase__							,outputs.logits							,atol=1e-3						)

		Path(lowerCAmelCase__						).mkdir(exist_ok=lowerCAmelCase__						)
		print(F"Saving model {model_name} to {pytorch_dump_folder_path}"						)
		model.save_pretrained(lowerCAmelCase__						)
		print(F"Saving image processor to {pytorch_dump_folder_path}"						)
		image_processor.save_pretrained(lowerCAmelCase__						)


if __name__ == "__main__":
		_lowercase		:  Dict			       =argparse.ArgumentParser()
		# Required parameters
		parser.add_argument(
		    """--model_name""",
		    default="""dino_vitb16""",
		    type=str,
		    help="""Name of the model trained with DINO you'd like to convert.""",
		)
		parser.add_argument(
		    """--pytorch_dump_folder_path""", default=None, type=str, help="""Path to the output PyTorch model directory."""
		)
		parser.add_argument(
		    """--base_model""",
		    action="""store_true""",
		    help="""Whether to only convert the base model (no projection head weights).""",
		)

		parser.set_defaults(base_model=True)
		_lowercase		:  int			       =parser.parse_args()
		convert_vit_checkpoint(args.model_name, args.pytorch_dump_folder_path, args.base_model)







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 						UpperCamelCase_  (  snake_case__							):



					def __init__(		self     :     str       ,      lowerCamelCase     :     Optional[int]       ,      lowerCamelCase     :     str=13       ,      lowerCamelCase     :     Optional[Any]=7       ,      lowerCamelCase     :     List[Any]=True       ,      lowerCamelCase     :     Dict=True       ,      lowerCamelCase     :     List[Any]=True       ,      lowerCamelCase     :     Any=True       ,      lowerCamelCase     :     Optional[Any]=99       ,      lowerCamelCase     :     Union[str, Any]=32       ,      lowerCamelCase     :     Any=5       ,      lowerCamelCase     :     Tuple=4       ,      lowerCamelCase     :     Optional[int]=37       ,      lowerCamelCase     :     Optional[Any]="gelu"       ,      lowerCamelCase     :     Optional[Any]=0.1       ,      lowerCamelCase     :     str=0.1       ,      lowerCamelCase     :     Tuple=5_12       ,      lowerCamelCase     :     Union[str, Any]=16       ,      lowerCamelCase     :     Union[str, Any]=2       ,      lowerCamelCase     :     Dict=0.02       ,      lowerCamelCase     :     Any=False       ,      lowerCamelCase     :     int=True       ,      lowerCamelCase     :     Optional[Any]="None"       ,      lowerCamelCase     :     Optional[int]=3       ,      lowerCamelCase     :     List[Any]=4       ,      lowerCamelCase     :     int=None       ,      ):
							lowerCamelCase_	:     int 						=      parent
							lowerCamelCase_	:     List[Any] 						=      batch_size
							lowerCamelCase_	:     Dict 						=      seq_length
							lowerCamelCase_	:     Union[str, Any] 						=      is_training
							lowerCamelCase_	:     str 						=      use_input_mask
							lowerCamelCase_	:     int 						=      use_token_type_ids
							lowerCamelCase_	:     Tuple 						=      use_labels
							lowerCamelCase_	:     str 						=      vocab_size
							lowerCamelCase_	:     int 						=      hidden_size
							lowerCamelCase_	:     Optional[int] 						=      num_hidden_layers
							lowerCamelCase_	:     Optional[Any] 						=      num_attention_heads
							lowerCamelCase_	:     Any 						=      intermediate_size
							lowerCamelCase_	:     List[Any] 						=      hidden_act
							lowerCamelCase_	:     List[Any] 						=      hidden_dropout_prob
							lowerCamelCase_	:     List[Any] 						=      attention_probs_dropout_prob
							lowerCamelCase_	:     List[str] 						=      max_position_embeddings
							lowerCamelCase_	:     Tuple 						=      type_vocab_size
							lowerCamelCase_	:     str 						=      type_sequence_label_size
							lowerCamelCase_	:     Optional[int] 						=      initializer_range
							lowerCamelCase_	:     List[Any] 						=      num_labels
							lowerCamelCase_	:     str 						=      num_choices
							lowerCamelCase_	:     Dict 						=      relative_attention
							lowerCamelCase_	:     Optional[int] 						=      position_biased_input
							lowerCamelCase_	:     List[Any] 						=      pos_att_type
							lowerCamelCase_	:     Optional[int] 						=      scope



					def   __a     (		self     :     List[Any]						):
							lowerCamelCase_	:     Tuple 						=      ids_tensor([self.batch_size, self.seq_length]       ,      self.vocab_size						)

							lowerCamelCase_	:     Dict 						=      None
							if self.use_input_mask:
									lowerCamelCase_	:     Optional[int] 						=      ids_tensor([self.batch_size, self.seq_length]       ,      vocab_size=2						)

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

							lowerCamelCase_	:     Union[str, Any] 						=      None
							lowerCamelCase_	:     List[Any] 						=      None
							lowerCamelCase_	:     str 						=      None
							if self.use_labels:
									lowerCamelCase_	:     Any 						=      ids_tensor([self.batch_size]       ,      self.type_sequence_label_size						)
									lowerCamelCase_	:     Optional[Any] 						=      ids_tensor([self.batch_size, self.seq_length]       ,      self.num_labels						)
									lowerCamelCase_	:     Any 						=      ids_tensor([self.batch_size]       ,      self.num_choices						)

							lowerCamelCase_	:     Optional[Any] 						=      self.get_config()

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



					def   __a     (		self     :     Tuple						):
							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   __a     (		self     :     int						):
							lowerCamelCase_	:     int 						=      self.get_config()
							lowerCamelCase_	:     Any 						=      3_00
							return config



					def   __a     (		self     :     Optional[int]       ,      lowerCamelCase     :     Dict						):
							self.parent.assertListEqual(list(result.loss.size()						)       ,      []						)



					def   __a     (		self     :     Dict       ,      lowerCamelCase     :     Tuple       ,      lowerCamelCase     :     List[Any]       ,      lowerCamelCase     :     Tuple       ,      lowerCamelCase     :     Any       ,      lowerCamelCase     :     Tuple       ,      lowerCamelCase     :     str       ,      lowerCamelCase     :     List[str]						):
							lowerCamelCase_	:     str 						=      DebertaModel(config=lowerCamelCase						)
							model.to(lowerCamelCase						)
							model.eval()
							lowerCamelCase_	:     Optional[int] 						=      model(lowerCamelCase       ,      attention_mask=lowerCamelCase       ,      token_type_ids=lowerCamelCase						)[0]
							lowerCamelCase_	:     Union[str, Any] 						=      model(lowerCamelCase       ,      token_type_ids=lowerCamelCase						)[0]
							lowerCamelCase_	:     List[Any] 						=      model(lowerCamelCase						)[0]

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



					def   __a     (		self     :     Optional[Any]       ,      lowerCamelCase     :     Tuple       ,      lowerCamelCase     :     str       ,      lowerCamelCase     :     str       ,      lowerCamelCase     :     int       ,      lowerCamelCase     :     int       ,      lowerCamelCase     :     str       ,      lowerCamelCase     :     Any						):
							lowerCamelCase_	:     Any 						=      DebertaForMaskedLM(config=lowerCamelCase						)
							model.to(lowerCamelCase						)
							model.eval()
							lowerCamelCase_	:     Any 						=      model(lowerCamelCase       ,      attention_mask=lowerCamelCase       ,      token_type_ids=lowerCamelCase       ,      labels=lowerCamelCase						)

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



					def   __a     (		self     :     Tuple       ,      lowerCamelCase     :     Any       ,      lowerCamelCase     :     Any       ,      lowerCamelCase     :     int       ,      lowerCamelCase     :     str       ,      lowerCamelCase     :     Optional[int]       ,      lowerCamelCase     :     Optional[int]       ,      lowerCamelCase     :     Tuple						):
							lowerCamelCase_	:     List[str] 						=      self.num_labels
							lowerCamelCase_	:     str 						=      DebertaForSequenceClassification(lowerCamelCase						)
							model.to(lowerCamelCase						)
							model.eval()
							lowerCamelCase_	:     List[str] 						=      model(lowerCamelCase       ,      attention_mask=lowerCamelCase       ,      token_type_ids=lowerCamelCase       ,      labels=lowerCamelCase						)
							self.parent.assertListEqual(list(result.logits.size()						)       ,      [self.batch_size, self.num_labels]						)
							self.check_loss_output(lowerCamelCase						)



					def   __a     (		self     :     List[str]       ,      lowerCamelCase     :     Dict       ,      lowerCamelCase     :     Tuple       ,      lowerCamelCase     :     str       ,      lowerCamelCase     :     Optional[int]       ,      lowerCamelCase     :     Tuple       ,      lowerCamelCase     :     List[str]       ,      lowerCamelCase     :     Optional[int]						):
							lowerCamelCase_	:     List[Any] 						=      self.num_labels
							lowerCamelCase_	:     str 						=      DebertaForTokenClassification(config=lowerCamelCase						)
							model.to(lowerCamelCase						)
							model.eval()
							lowerCamelCase_	:     List[str] 						=      model(lowerCamelCase       ,      attention_mask=lowerCamelCase       ,      token_type_ids=lowerCamelCase       ,      labels=lowerCamelCase						)
							self.parent.assertEqual(result.logits.shape       ,      (self.batch_size, self.seq_length, self.num_labels)						)



					def   __a     (		self     :     List[str]       ,      lowerCamelCase     :     Union[str, Any]       ,      lowerCamelCase     :     List[Any]       ,      lowerCamelCase     :     int       ,      lowerCamelCase     :     Union[str, Any]       ,      lowerCamelCase     :     List[Any]       ,      lowerCamelCase     :     List[str]       ,      lowerCamelCase     :     str						):
							lowerCamelCase_	:     int 						=      DebertaForQuestionAnswering(config=lowerCamelCase						)
							model.to(lowerCamelCase						)
							model.eval()
							lowerCamelCase_	:     List[Any] 						=      model(
							    lowerCamelCase       ,      attention_mask=lowerCamelCase       ,      token_type_ids=lowerCamelCase       ,      start_positions=lowerCamelCase       ,      end_positions=lowerCamelCase       ,      )
							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   __a     (		self     :     int						):
							lowerCamelCase_	:     Any 						=      self.prepare_config_and_inputs()
							(
							    (
							    lowerCamelCase_
							)						,      (
							    lowerCamelCase_
							)						,      (
							    lowerCamelCase_
							)						,      (
							    lowerCamelCase_
							)						,      (
							    lowerCamelCase_
							)						,      (
							    lowerCamelCase_
							)						,      (
							    lowerCamelCase_
							)						,      
							)	:     Dict 						=      config_and_inputs
							lowerCamelCase_	:     str 						=      {'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
							return config, inputs_dict






@require_torch
class 						UpperCamelCase_  (  snake_case__  ,     snake_case__  ,     unittest.TestCase							):
					_a      :						str						    =					(
					    (
					        DebertaModel,
					        DebertaForMaskedLM,
					        DebertaForSequenceClassification,
					        DebertaForTokenClassification,
					        DebertaForQuestionAnswering,
					    )
					    if is_torch_available()
					    else ()
					)
					_a      :						Any						    =					(
					    {
					        'feature-extraction': DebertaModel,
					        'fill-mask': DebertaForMaskedLM,
					        'question-answering': DebertaForQuestionAnswering,
					        'text-classification': DebertaForSequenceClassification,
					        'token-classification': DebertaForTokenClassification,
					        'zero-shot': DebertaForSequenceClassification,
					    }
					    if is_torch_available()
					    else {}
					)

					_a      :						Optional[int]						    =					True
					_a      :						List[str]						    =					False
					_a      :						List[str]						    =					False
					_a      :						List[str]						    =					False
					_a      :						List[Any]						    =					False



					def   __a     (		self     :     List[str]						):
							lowerCamelCase_	:     List[Any] 						=      DebertaModelTester(self						)
							lowerCamelCase_	:     Any 						=      ConfigTester(self       ,      config_class=lowerCamelCase       ,      hidden_size=37						)



					def   __a     (		self     :     Any						):
							self.config_tester.run_common_tests()



					def   __a     (		self     :     List[str]						):
							lowerCamelCase_	:     int 						=      self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_deberta_model(*lowerCamelCase						)



					def   __a     (		self     :     int						):
							lowerCamelCase_	:     str 						=      self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_deberta_for_sequence_classification(*lowerCamelCase						)



					def   __a     (		self     :     Optional[int]						):
							lowerCamelCase_	:     Optional[Any] 						=      self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_deberta_for_masked_lm(*lowerCamelCase						)



					def   __a     (		self     :     str						):
							lowerCamelCase_	:     List[Any] 						=      self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_deberta_for_question_answering(*lowerCamelCase						)



					def   __a     (		self     :     Union[str, Any]						):
							lowerCamelCase_	:     List[Any] 						=      self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_deberta_for_token_classification(*lowerCamelCase						)





					@slow
					def   __a     (		self     :     Optional[int]						):
							for model_name in DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									lowerCamelCase_	:     Optional[int] 						=      DebertaModel.from_pretrained(lowerCamelCase						)
									self.assertIsNotNone(lowerCamelCase						)






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



					@unittest.skip(reason='Model not available yet'						)
					def   __a     (		self     :     str						):
							pass





					@slow
					def   __a     (		self     :     Dict						):
							lowerCamelCase_	:     List[str] 						=      DebertaModel.from_pretrained('microsoft/deberta-base'						)

							lowerCamelCase_	:     Optional[Any] 						=      torch.tensor([[0, 3_14_14, 2_32, 3_28, 7_40, 11_40, 1_26_95, 69, 4_60_78, 15_88, 2]]						)
							lowerCamelCase_	:     List[str] 						=      torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]						)
							with torch.no_grad():
									lowerCamelCase_	:     Dict 						=      model(lowerCamelCase       ,      attention_mask=lowerCamelCase						)[0]
							# compare the actual values for a slice.
							lowerCamelCase_	:     str 						=      torch.tensor(
							    [[[-0.5_986, -0.8_055, -0.8_462], [1.4_484, -0.9_348, -0.8_059], [0.3_123, 0.0_032, -1.4_131]]]						)
							self.assertTrue(torch.allclose(output[:, 1:4, 1:4]       ,      lowerCamelCase       ,      atol=1E-4						)       ,      F"{output[:, 1:4, 1:4]}"						)
