
from typing import List, Optional, Union

import torch

from ...models import UNetaDConditionModel, VQModel
from ...pipelines import DiffusionPipeline
from ...pipelines.pipeline_utils import ImagePipelineOutput
from ...schedulers import DDPMScheduler
from ...utils import (
    is_accelerate_available,
    is_accelerate_version,
    logging,
    randn_tensor,
    replace_example_docstring,
)


lowercase   =	logging.get_logger(__name__)  # pylint: disable=invalid-name

lowercase   =	'''
    Examples:
        ```py
        >>> import torch
        >>> import numpy as np

        >>> from diffusers import KandinskyV22PriorPipeline, KandinskyV22ControlnetPipeline
        >>> from transformers import pipeline
        >>> from diffusers.utils import load_image


        >>> def make_hint(image, depth_estimator):
        ...     image = depth_estimator(image)["depth"]
        ...     image = np.array(image)
        ...     image = image[:, :, None]
        ...     image = np.concatenate([image, image, image], axis=2)
        ...     detected_map = torch.from_numpy(image).float() / 255.0
        ...     hint = detected_map.permute(2, 0, 1)
        ...     return hint


        >>> depth_estimator = pipeline("depth-estimation")

        >>> pipe_prior = KandinskyV22PriorPipeline.from_pretrained(
        ...     "kandinsky-community/kandinsky-2-2-prior", torch_dtype=torch.float16
        ... )
        >>> pipe_prior = pipe_prior.to("cuda")

        >>> pipe = KandinskyV22ControlnetPipeline.from_pretrained(
        ...     "kandinsky-community/kandinsky-2-2-controlnet-depth", torch_dtype=torch.float16
        ... )
        >>> pipe = pipe.to("cuda")


        >>> img = load_image(
        ...     "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
        ...     "/kandinsky/cat.png"
        ... ).resize((768, 768))

        >>> hint = make_hint(img, depth_estimator).unsqueeze(0).half().to("cuda")

        >>> prompt = "A robot, 4k photo"
        >>> negative_prior_prompt = "lowres, text, error, cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, username, watermark, signature"

        >>> generator = torch.Generator(device="cuda").manual_seed(43)

        >>> image_emb, zero_image_emb = pipe_prior(
        ...     prompt=prompt, negative_prompt=negative_prior_prompt, generator=generator
        ... ).to_tuple()

        >>> images = pipe(
        ...     image_embeds=image_emb,
        ...     negative_image_embeds=zero_image_emb,
        ...     hint=hint,
        ...     num_inference_steps=50,
        ...     generator=generator,
        ...     height=768,
        ...     width=768,
        ... ).images

        >>> images[0].save("robot_cat.png")
        ```
'''



def   __lowerCAmelCase    (				UpperCAmelCase__					:   Any      ,					UpperCAmelCase__					:   Union[str, Any]      ,					UpperCAmelCase__					:   List[str]=8							)	->     str:
							lowerCamelCase_					=       height // scale_factor**2
							if height % scale_factor**2 != 0:
														new_height += 1
							lowerCamelCase_					=       width // scale_factor**2
							if width % scale_factor**2 != 0:
														new_width += 1
							return new_height * scale_factor, new_width * scale_factor





class    __A(					UpperCAmelCase							):

					def __init__(						self       :  Optional[Any] ,       __UpperCamelCase       :  UNetaDConditionModel ,       __UpperCamelCase       :  DDPMScheduler ,       __UpperCamelCase       :  VQModel ,       ):
												super().__init__()

												self.register_modules(
												    unet=__UpperCamelCase ,       scheduler=__UpperCamelCase ,       movq=__UpperCamelCase ,       )
												lowerCamelCase_					=       2 ** (len(self.movq.config.block_out_channels ) - 1)

					def  lowercase__   (						self       :  Optional[Any] ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  Optional[Any] ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  Dict ,       __UpperCamelCase       :  int ):
												if latents is None:
																			lowerCamelCase_					=       randn_tensor(__UpperCamelCase ,       generator=__UpperCamelCase ,       device=__UpperCamelCase ,       dtype=__UpperCamelCase )
												else:
																			if latents.shape != shape:
																										raise ValueError(F'''Unexpected latents shape, got {latents.shape}, expected {shape}''' )
																			lowerCamelCase_					=       latents.to(__UpperCamelCase )

												lowerCamelCase_					=       latents * scheduler.init_noise_sigma
												return latents

					def  lowercase__   (						self       :  Optional[int] ,       __UpperCamelCase       :  List[str]=0 ):
												if is_accelerate_available():
																			from accelerate import cpu_offload
												else:
																			raise ImportError("""Please install accelerate via `pip install accelerate`""" )

												lowerCamelCase_					=       torch.device(F'''cuda:{gpu_id}''' )

												lowerCamelCase_					=       [
												    self.unet,
												    self.movq,
												]
												for cpu_offloaded_model in models:
																			if cpu_offloaded_model is not None:
																										cpu_offload(__UpperCamelCase ,       __UpperCamelCase )

					def  lowercase__   (						self       :  Tuple ,       __UpperCamelCase       :  Any=0 ):
												if is_accelerate_available() and is_accelerate_version(""">=""" ,       """0.17.0.dev0""" ):
																			from accelerate import cpu_offload_with_hook
												else:
																			raise ImportError("""`enable_model_cpu_offload` requires `accelerate v0.17.0` or higher.""" )

												lowerCamelCase_					=       torch.device(F'''cuda:{gpu_id}''' )

												if self.device.type != "cpu":
																			self.to("""cpu""" ,       silence_dtype_warnings=__UpperCamelCase )
																			torch.cuda.empty_cache()  # otherwise we don't see the memory savings (but they probably exist)

												lowerCamelCase_					=       None
												for cpu_offloaded_model in [self.unet, self.movq]:
																			lowerCamelCase_	, lowerCamelCase_					=       cpu_offload_with_hook(__UpperCamelCase ,       __UpperCamelCase ,       prev_module_hook=__UpperCamelCase )

												# We'll offload the last model manually.
												lowerCamelCase_					=       hook

					@property
					# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline._execution_device
					def  lowercase__   (						self       :  Optional[Any] ):
												if not hasattr(self.unet ,       """_hf_hook""" ):
																			return self.device
												for module in self.unet.modules():
																			if (
																			    hasattr(__UpperCamelCase ,       """_hf_hook""" )
																			    and hasattr(module._hf_hook ,       """execution_device""" )
																			    and module._hf_hook.execution_device is not None
																			):
																										return torch.device(module._hf_hook.execution_device )
												return self.device



					@torch.no_grad()
					@replace_example_docstring(__UpperCamelCase )
					def __call__(						self       :  List[str] ,       __UpperCamelCase       :  Union[torch.FloatTensor, List[torch.FloatTensor]] ,       __UpperCamelCase       :  Union[torch.FloatTensor, List[torch.FloatTensor]] ,       __UpperCamelCase       :  torch.FloatTensor ,       __UpperCamelCase       :  int = 5_1_2 ,       __UpperCamelCase       :  int = 5_1_2 ,       __UpperCamelCase       :  int = 1_0_0 ,       __UpperCamelCase       :  float = 4.0 ,       __UpperCamelCase       :  int = 1 ,       __UpperCamelCase       :  Optional[Union[torch.Generator, List[torch.Generator]]] = None ,       __UpperCamelCase       :  Optional[torch.FloatTensor] = None ,       __UpperCamelCase       :  Optional[str] = "pil" ,       __UpperCamelCase       :  bool = True ,       ):
												lowerCamelCase_					=       self._execution_device

												lowerCamelCase_					=       guidance_scale > 1.0

												if isinstance(__UpperCamelCase ,       __UpperCamelCase ):
																			lowerCamelCase_					=       torch.cat(__UpperCamelCase ,       dim=0 )
												if isinstance(__UpperCamelCase ,       __UpperCamelCase ):
																			lowerCamelCase_					=       torch.cat(__UpperCamelCase ,       dim=0 )
												if isinstance(__UpperCamelCase ,       __UpperCamelCase ):
																			lowerCamelCase_					=       torch.cat(__UpperCamelCase ,       dim=0 )

												lowerCamelCase_					=       image_embeds.shape[0] * num_images_per_prompt

												if do_classifier_free_guidance:
																			lowerCamelCase_					=       image_embeds.repeat_interleave(__UpperCamelCase ,       dim=0 )
																			lowerCamelCase_					=       negative_image_embeds.repeat_interleave(__UpperCamelCase ,       dim=0 )
																			lowerCamelCase_					=       hint.repeat_interleave(__UpperCamelCase ,       dim=0 )

												lowerCamelCase_					=       torch.cat([negative_image_embeds, image_embeds] ,       dim=0 ).to(dtype=self.unet.dtype ,       device=__UpperCamelCase )
												lowerCamelCase_					=       torch.cat([hint, hint] ,       dim=0 ).to(dtype=self.unet.dtype ,       device=__UpperCamelCase )
												self.scheduler.set_timesteps(__UpperCamelCase ,       device=__UpperCamelCase )
												lowerCamelCase_					=       self.scheduler.timesteps

												lowerCamelCase_					=       self.movq.config.latent_channels

												lowerCamelCase_	, lowerCamelCase_					=       downscale_height_and_width(__UpperCamelCase ,       __UpperCamelCase ,       self.movq_scale_factor )

												# create initial latent
												lowerCamelCase_					=       self.prepare_latents(
												    (batch_size, num_channels_latents, height, width) ,       image_embeds.dtype ,       __UpperCamelCase ,       __UpperCamelCase ,       __UpperCamelCase ,       self.scheduler ,       )

												for i, t in enumerate(self.progress_bar(__UpperCamelCase ) ):
																			# expand the latents if we are doing classifier free guidance
																			lowerCamelCase_					=       torch.cat([latents] * 2 ) if do_classifier_free_guidance else latents

																			lowerCamelCase_					=       {"""image_embeds""": image_embeds, """hint""": hint}
																			lowerCamelCase_					=       self.unet(
																			    sample=__UpperCamelCase ,       timestep=__UpperCamelCase ,       encoder_hidden_states=__UpperCamelCase ,       added_cond_kwargs=__UpperCamelCase ,       return_dict=__UpperCamelCase ,       )[0]

																			if do_classifier_free_guidance:
																										lowerCamelCase_	, lowerCamelCase_					=       noise_pred.split(latents.shape[1] ,       dim=1 )
																										lowerCamelCase_	, lowerCamelCase_					=       noise_pred.chunk(2 )
																										lowerCamelCase_	, lowerCamelCase_					=       variance_pred.chunk(2 )
																										lowerCamelCase_					=       noise_pred_uncond + guidance_scale * (noise_pred_text - noise_pred_uncond)
																										lowerCamelCase_					=       torch.cat([noise_pred, variance_pred_text] ,       dim=1 )

																			if not (
																			    hasattr(self.scheduler.config ,       """variance_type""" )
																			    and self.scheduler.config.variance_type in ["learned", "learned_range"]
																			):
																										lowerCamelCase_	, lowerCamelCase_					=       noise_pred.split(latents.shape[1] ,       dim=1 )

																			# compute the previous noisy sample x_t -> x_t-1
																			lowerCamelCase_					=       self.scheduler.step(
																			    __UpperCamelCase ,       __UpperCamelCase ,       __UpperCamelCase ,       generator=__UpperCamelCase ,       )[0]
												# post-processing
												lowerCamelCase_					=       self.movq.decode(__UpperCamelCase ,       force_not_quantize=__UpperCamelCase )["""sample"""]

												if output_type not in ["pt", "np", "pil"]:
																			raise ValueError(F'''Only the output types `pt`, `pil` and `np` are supported not output_type={output_type}''' )

												if output_type in ["np", "pil"]:
																			lowerCamelCase_					=       image * 0.5 + 0.5
																			lowerCamelCase_					=       image.clamp(0 ,       1 )
																			lowerCamelCase_					=       image.cpu().permute(0 ,       2 ,       3 ,       1 ).float().numpy()

												if output_type == "pil":
																			lowerCamelCase_					=       self.numpy_to_pil(__UpperCamelCase )

												if not return_dict:
																			return (image,)

												return ImagePipelineOutput(images=__UpperCamelCase )







from __future__ import annotations

import unittest

from transformers import DebertaVaConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
		import tensorflow as tf

		from transformers import (
		    TFDebertaVaForMaskedLM,
		    TFDebertaVaForQuestionAnswering,
		    TFDebertaVaForSequenceClassification,
		    TFDebertaVaForTokenClassification,
		    TFDebertaVaModel,
		)





class    __A:

					def __init__(						self       :  List[Any] ,       __UpperCamelCase       :  Tuple ,       __UpperCamelCase       :  Any=1_3 ,       __UpperCamelCase       :  Optional[int]=7 ,       __UpperCamelCase       :  Any=True ,       __UpperCamelCase       :  Dict=True ,       __UpperCamelCase       :  Optional[Any]=True ,       __UpperCamelCase       :  Dict=True ,       __UpperCamelCase       :  Union[str, Any]=9_9 ,       __UpperCamelCase       :  List[str]=3_2 ,       __UpperCamelCase       :  int=2 ,       __UpperCamelCase       :  Optional[Any]=4 ,       __UpperCamelCase       :  Optional[int]=3_7 ,       __UpperCamelCase       :  Optional[Any]="gelu" ,       __UpperCamelCase       :  int=0.1 ,       __UpperCamelCase       :  str=0.1 ,       __UpperCamelCase       :  Tuple=5_1_2 ,       __UpperCamelCase       :  Any=1_6 ,       __UpperCamelCase       :  Dict=2 ,       __UpperCamelCase       :  Optional[Any]=0.02 ,       __UpperCamelCase       :  Optional[Any]=False ,       __UpperCamelCase       :  Dict=True ,       __UpperCamelCase       :  Any="None" ,       __UpperCamelCase       :  List[Any]=3 ,       __UpperCamelCase       :  Optional[int]=4 ,       __UpperCamelCase       :  Dict=None ,       ):
												lowerCamelCase_					=       parent
												lowerCamelCase_					=       batch_size
												lowerCamelCase_					=       seq_length
												lowerCamelCase_					=       is_training
												lowerCamelCase_					=       use_input_mask
												lowerCamelCase_					=       use_token_type_ids
												lowerCamelCase_					=       use_labels
												lowerCamelCase_					=       vocab_size
												lowerCamelCase_					=       hidden_size
												lowerCamelCase_					=       num_hidden_layers
												lowerCamelCase_					=       num_attention_heads
												lowerCamelCase_					=       intermediate_size
												lowerCamelCase_					=       hidden_act
												lowerCamelCase_					=       hidden_dropout_prob
												lowerCamelCase_					=       attention_probs_dropout_prob
												lowerCamelCase_					=       max_position_embeddings
												lowerCamelCase_					=       type_vocab_size
												lowerCamelCase_					=       type_sequence_label_size
												lowerCamelCase_					=       initializer_range
												lowerCamelCase_					=       num_labels
												lowerCamelCase_					=       num_choices
												lowerCamelCase_					=       relative_attention
												lowerCamelCase_					=       position_biased_input
												lowerCamelCase_					=       pos_att_type
												lowerCamelCase_					=       scope

					def  lowercase__   (						self       :  Optional[Any] ):
												lowerCamelCase_					=       ids_tensor([self.batch_size, self.seq_length] ,       self.vocab_size )

												lowerCamelCase_					=       None
												if self.use_input_mask:
																			lowerCamelCase_					=       random_attention_mask([self.batch_size, self.seq_length] )

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

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

												lowerCamelCase_					=       DebertaVaConfig(
												    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 ,       relative_attention=self.relative_attention ,       position_biased_input=self.position_biased_input ,       initializer_range=self.initializer_range ,       return_dict=__UpperCamelCase ,       )

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

					def  lowercase__   (						self       :  str ,       __UpperCamelCase       :  Union[str, Any] ,       __UpperCamelCase       :  Optional[int] ,       __UpperCamelCase       :  Optional[Any] ,       __UpperCamelCase       :  Optional[int] ,       __UpperCamelCase       :  Any ,       __UpperCamelCase       :  int ,       __UpperCamelCase       :  List[str] ):
												lowerCamelCase_					=       TFDebertaVaModel(config=__UpperCamelCase )
												lowerCamelCase_					=       {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}

												lowerCamelCase_					=       [input_ids, input_mask]
												lowerCamelCase_					=       model(__UpperCamelCase )

												lowerCamelCase_					=       model(__UpperCamelCase )

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

					def  lowercase__   (						self       :  Optional[int] ,       __UpperCamelCase       :  List[str] ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  Dict ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  List[str] ,       __UpperCamelCase       :  Tuple ,       __UpperCamelCase       :  int ):
												lowerCamelCase_					=       TFDebertaVaForMaskedLM(config=__UpperCamelCase )
												lowerCamelCase_					=       {
												    """input_ids""": input_ids,
												    """attention_mask""": input_mask,
												    """token_type_ids""": token_type_ids,
												}
												lowerCamelCase_					=       model(__UpperCamelCase )
												self.parent.assertEqual(result.logits.shape ,       (self.batch_size, self.seq_length, self.vocab_size) )

					def  lowercase__   (						self       :  List[Any] ,       __UpperCamelCase       :  Union[str, Any] ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  int ,       __UpperCamelCase       :  Optional[int] ,       __UpperCamelCase       :  List[Any] ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  List[Any] ):
												lowerCamelCase_					=       self.num_labels
												lowerCamelCase_					=       TFDebertaVaForSequenceClassification(config=__UpperCamelCase )
												lowerCamelCase_					=       {
												    """input_ids""": input_ids,
												    """attention_mask""": input_mask,
												    """token_type_ids""": token_type_ids,
												}

												lowerCamelCase_					=       model(__UpperCamelCase )
												self.parent.assertEqual(result.logits.shape ,       (self.batch_size, self.num_labels) )

					def  lowercase__   (						self       :  int ,       __UpperCamelCase       :  Tuple ,       __UpperCamelCase       :  Any ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  Optional[int] ,       __UpperCamelCase       :  List[str] ,       __UpperCamelCase       :  List[Any] ,       __UpperCamelCase       :  List[Any] ):
												lowerCamelCase_					=       self.num_labels
												lowerCamelCase_					=       TFDebertaVaForTokenClassification(config=__UpperCamelCase )
												lowerCamelCase_					=       {
												    """input_ids""": input_ids,
												    """attention_mask""": input_mask,
												    """token_type_ids""": token_type_ids,
												}
												lowerCamelCase_					=       model(__UpperCamelCase )
												self.parent.assertEqual(result.logits.shape ,       (self.batch_size, self.seq_length, self.num_labels) )

					def  lowercase__   (						self       :  List[Any] ,       __UpperCamelCase       :  Optional[int] ,       __UpperCamelCase       :  Optional[Any] ,       __UpperCamelCase       :  Optional[int] ,       __UpperCamelCase       :  str ,       __UpperCamelCase       :  Optional[Any] ,       __UpperCamelCase       :  List[str] ,       __UpperCamelCase       :  int ):
												lowerCamelCase_					=       TFDebertaVaForQuestionAnswering(config=__UpperCamelCase )
												lowerCamelCase_					=       {
												    """input_ids""": input_ids,
												    """attention_mask""": input_mask,
												    """token_type_ids""": token_type_ids,
												}

												lowerCamelCase_					=       model(__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       :  Dict ):
												lowerCamelCase_					=       self.prepare_config_and_inputs()
												(
												    (
												    lowerCamelCase_
												)	, (
												    lowerCamelCase_
												)	, (
												    lowerCamelCase_
												)	, (
												    lowerCamelCase_
												)	, (
												    lowerCamelCase_
												)	, (
												    lowerCamelCase_
												)	, (
												    lowerCamelCase_
												)	, 
												)					=       config_and_inputs
												lowerCamelCase_					=       {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
												return config, inputs_dict





@require_tf
class    __A(					UpperCAmelCase  ,		UpperCAmelCase  ,		unittest.TestCase							):
					SCREAMING_SNAKE_CASE           =     (
					    (
					        TFDebertaVaModel,
					        TFDebertaVaForMaskedLM,
					        TFDebertaVaForQuestionAnswering,
					        TFDebertaVaForSequenceClassification,
					        TFDebertaVaForTokenClassification,
					    )
					    if is_tf_available()
					    else ()
					)
					SCREAMING_SNAKE_CASE           =     (
					    {
					        '''feature-extraction''': TFDebertaVaModel,
					        '''fill-mask''': TFDebertaVaForMaskedLM,
					        '''question-answering''': TFDebertaVaForQuestionAnswering,
					        '''text-classification''': TFDebertaVaForSequenceClassification,
					        '''token-classification''': TFDebertaVaForTokenClassification,
					        '''zero-shot''': TFDebertaVaForSequenceClassification,
					    }
					    if is_tf_available()
					    else {}
					)

					SCREAMING_SNAKE_CASE           =     False
					SCREAMING_SNAKE_CASE           =     False

					def  lowercase__   (						self       :  Dict ):
												lowerCamelCase_					=       TFDebertaVaModelTester(self )
												lowerCamelCase_					=       ConfigTester(self ,       config_class=__UpperCamelCase ,       hidden_size=3_7 )

					def  lowercase__   (						self       :  Dict ):
												self.config_tester.run_common_tests()

					def  lowercase__   (						self       :  Optional[Any] ):
												lowerCamelCase_					=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_model(*__UpperCamelCase )

					def  lowercase__   (						self       :  Dict ):
												lowerCamelCase_					=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_masked_lm(*__UpperCamelCase )

					def  lowercase__   (						self       :  List[Any] ):
												lowerCamelCase_					=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_question_answering(*__UpperCamelCase )

					def  lowercase__   (						self       :  Tuple ):
												lowerCamelCase_					=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_sequence_classification(*__UpperCamelCase )

					def  lowercase__   (						self       :  Any ):
												lowerCamelCase_					=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_token_classification(*__UpperCamelCase )



					@slow
					def  lowercase__   (						self       :  int ):
												lowerCamelCase_					=       TFDebertaVaModel.from_pretrained("""kamalkraj/deberta-v2-xlarge""" )
												self.assertIsNotNone(__UpperCamelCase )





@require_tf
class    __A(					unittest.TestCase							):

					@unittest.skip(reason="""Model not available yet""" )
					def  lowercase__   (						self       :  Optional[int] ):
												pass



					@slow
					def  lowercase__   (						self       :  Any ):
												lowerCamelCase_					=       TFDebertaVaModel.from_pretrained("""kamalkraj/deberta-v2-xlarge""" )
												lowerCamelCase_					=       tf.constant([[0, 3_1_4_1_4, 2_3_2, 3_2_8, 7_4_0, 1_1_4_0, 1_2_6_9_5, 6_9, 4_6_0_7_8, 1_5_8_8, 2]] )
												lowerCamelCase_					=       tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] )
												lowerCamelCase_					=       model(__UpperCamelCase ,       attention_mask=__UpperCamelCase )[0]

												lowerCamelCase_					=       tf.constant(
												    [[[0.2356, 0.1948, 0.0369], [-0.1063, 0.3586, -0.5152], [-0.6399, -0.0259, -0.2525]]] )
												tf.debugging.assert_near(output[:, 1:4, 1:4] ,       __UpperCamelCase ,       atol=1E-4 )





