


'''simple docstring'''





import unittest

import numpy as np
import PIL
import torch

from diffusers.image_processor import VaeImageProcessor





class       _a							(       unittest.TestCase):




	@property
	def 							UpperCAmelCase__(      self		:	int	)-> List[str]:
			lowerCAmelCase__     :    Tuple					  =      1
			lowerCAmelCase__     :    Dict					  =      3
			lowerCAmelCase__     :    str					  =      8
			lowerCAmelCase__     :    Optional[int]					  =      8

			lowerCAmelCase__     :    Optional[Any]					  =      torch.rand((batch_size, num_channels, height, width)	)

			return sample




	def 							UpperCAmelCase__(      self		:	int	,      _SCREAMING_SNAKE_CASE		:	int	)-> List[str]:


			if isinstance(image[0]	,      PIL.Image.Image	):
					return np.stack([np.array(__UpperCamelCase	) for i in image]	,      axis=0	)
			elif isinstance(__UpperCamelCase	,      torch.Tensor	):
					return image.cpu().numpy().transpose(0	,      2	,      3	,      1	)
			return image




	def 							UpperCAmelCase__(      self		:	Dict	)-> int:
			lowerCAmelCase__     :    List[Any]					  =      VaeImageProcessor(do_resize=__UpperCamelCase	,      do_normalize=__UpperCamelCase	)

			lowerCAmelCase__     :    Optional[Any]					  =      self.dummy_sample
			lowerCAmelCase__     :    Union[str, Any]					  =      self.to_np(__UpperCamelCase	)

			for output_type in ["pt", "np", "pil"]:
					lowerCAmelCase__     :    List[str]					  =      image_processor.postprocess(
					    image_processor.preprocess(__UpperCamelCase	)	,      output_type=__UpperCamelCase	,      )
					lowerCAmelCase__     :    Dict					  =      self.to_np(__UpperCamelCase	)
					lowerCAmelCase__     :    Tuple					  =      (input_np * 255).round() if output_type == '''pil''' else input_np
					assert (
					    np.abs(in_np - out_np	).max() < 1E-6
					), F'decoded output does not match input for output_type {output_type}'




	def 							UpperCAmelCase__(      self		:	Tuple	)-> Any:
			lowerCAmelCase__     :    str					  =      VaeImageProcessor(do_resize=__UpperCamelCase	,      do_normalize=__UpperCamelCase	)
			lowerCAmelCase__     :    Union[str, Any]					  =      self.dummy_sample.cpu().numpy().transpose(0	,      2	,      3	,      1	)

			for output_type in ["pt", "np", "pil"]:
					lowerCAmelCase__     :    Union[str, Any]					  =      image_processor.postprocess(image_processor.preprocess(__UpperCamelCase	)	,      output_type=__UpperCamelCase	)

					lowerCAmelCase__     :    Any					  =      self.to_np(__UpperCamelCase	)
					lowerCAmelCase__     :    Optional[Any]					  =      (input_np * 255).round() if output_type == '''pil''' else input_np
					assert (
					    np.abs(in_np - out_np	).max() < 1E-6
					), F'decoded output does not match input for output_type {output_type}'




	def 							UpperCAmelCase__(      self		:	Optional[Any]	)-> Union[str, Any]:
			lowerCAmelCase__     :    Dict					  =      VaeImageProcessor(do_resize=__UpperCamelCase	,      do_normalize=__UpperCamelCase	)

			lowerCAmelCase__     :    str					  =      self.dummy_sample.cpu().numpy().transpose(0	,      2	,      3	,      1	)
			lowerCAmelCase__     :    Optional[int]					  =      image_processor.numpy_to_pil(__UpperCamelCase	)

			for output_type in ["pt", "np", "pil"]:
					lowerCAmelCase__     :    Tuple					  =      image_processor.postprocess(image_processor.preprocess(__UpperCamelCase	)	,      output_type=__UpperCamelCase	)
					for i, o in zip(__UpperCamelCase	,      __UpperCamelCase	):
							lowerCAmelCase__     :    Tuple					  =      np.array(__UpperCamelCase	)
							lowerCAmelCase__     :    int					  =      self.to_np(__UpperCamelCase	) if output_type == '''pil''' else (self.to_np(__UpperCamelCase	) * 255).round()
							assert (
							    np.abs(in_np - out_np	).max() < 1E-6
							), F'decoded output does not match input for output_type {output_type}'




	def 							UpperCAmelCase__(      self		:	Optional[Any]	)-> Union[str, Any]:
			lowerCAmelCase__     :    Optional[int]					  =      VaeImageProcessor(do_resize=__UpperCamelCase	,      do_normalize=__UpperCamelCase	)

			lowerCAmelCase__     :    Optional[Any]					  =      self.dummy_sample
			lowerCAmelCase__     :    List[Any]					  =      input_pt_ad.squeeze(0	)

			lowerCAmelCase__     :    Union[str, Any]					  =      image_processor.postprocess(
			    image_processor.preprocess(__UpperCamelCase	)	,      output_type='''np'''	,      )
			lowerCAmelCase__     :    int					  =      image_processor.postprocess(
			    image_processor.preprocess(__UpperCamelCase	)	,      output_type='''np'''	,      )

			lowerCAmelCase__     :    List[Any]					  =      self.to_np(self.dummy_sample	)
			lowerCAmelCase__     :    str					  =      input_np_ad.squeeze(0	)

			lowerCAmelCase__     :    Any					  =      image_processor.postprocess(
			    image_processor.preprocess(__UpperCamelCase	)	,      output_type='''np'''	,      )
			lowerCAmelCase__     :    List[Any]					  =      image_processor.postprocess(
			    image_processor.preprocess(__UpperCamelCase	)	,      output_type='''np'''	,      )

			assert np.abs(out_pt_ad - out_pt_ad	).max() < 1E-6
			assert np.abs(out_np_ad - out_np_ad	).max() < 1E-6




	def 							UpperCAmelCase__(      self		:	Optional[int]	)-> List[str]:
			lowerCAmelCase__     :    Optional[int]					  =      VaeImageProcessor(do_resize=__UpperCamelCase	,      do_normalize=__UpperCamelCase	)

			lowerCAmelCase__     :    Any					  =      self.dummy_sample
			lowerCAmelCase__     :    Optional[Any]					  =      list(__UpperCamelCase	)

			lowerCAmelCase__     :    List[str]					  =      image_processor.postprocess(
			    image_processor.preprocess(__UpperCamelCase	)	,      output_type='''np'''	,      )

			lowerCAmelCase__     :    Tuple					  =      image_processor.postprocess(
			    image_processor.preprocess(__UpperCamelCase	)	,      output_type='''np'''	,      )

			lowerCAmelCase__     :    List[Any]					  =      self.to_np(self.dummy_sample	)
			list(__UpperCamelCase	)

			lowerCAmelCase__     :    str					  =      image_processor.postprocess(
			    image_processor.preprocess(__UpperCamelCase	)	,      output_type='''np'''	,      )

			lowerCAmelCase__     :    Tuple					  =      image_processor.postprocess(
			    image_processor.preprocess(__UpperCamelCase	)	,      output_type='''np'''	,      )

			assert np.abs(out_pt_ad - out_pt_list	).max() < 1E-6
			assert np.abs(out_np_ad - out_np_list	).max() < 1E-6








from __future__ import annotations

import unittest

from transformers import AlbertConfig, is_tf_available
from transformers.models.auto import get_values
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 TF_MODEL_FOR_PRETRAINING_MAPPING
		from transformers.models.albert.modeling_tf_albert import (
		    TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFAlbertForMaskedLM,
		    TFAlbertForMultipleChoice,
		    TFAlbertForPreTraining,
		    TFAlbertForQuestionAnswering,
		    TFAlbertForSequenceClassification,
		    TFAlbertForTokenClassification,
		    TFAlbertModel,
		)





class       _a							:




	def __init__(      self		:	Tuple	,      _SCREAMING_SNAKE_CASE		:	List[Any]	,      _SCREAMING_SNAKE_CASE		:	Tuple=13	,      _SCREAMING_SNAKE_CASE		:	Dict=7	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]=True	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=True	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=True	,      _SCREAMING_SNAKE_CASE		:	int=True	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]=99	,      _SCREAMING_SNAKE_CASE		:	int=16	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]=32	,      _SCREAMING_SNAKE_CASE		:	Tuple=2	,      _SCREAMING_SNAKE_CASE		:	int=4	,      _SCREAMING_SNAKE_CASE		:	List[str]=37	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]="gelu"	,      _SCREAMING_SNAKE_CASE		:	List[Any]=0.1	,      _SCREAMING_SNAKE_CASE		:	List[Any]=0.1	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]=512	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]=16	,      _SCREAMING_SNAKE_CASE		:	str=2	,      _SCREAMING_SNAKE_CASE		:	Optional[int]=0.02	,      _SCREAMING_SNAKE_CASE		:	Any=3	,      _SCREAMING_SNAKE_CASE		:	Dict=4	,      _SCREAMING_SNAKE_CASE		:	int=None	,      )-> str:
			lowerCAmelCase__     :    Any					  =      parent
			lowerCAmelCase__     :    List[Any]					  =      13
			lowerCAmelCase__     :    int					  =      7
			lowerCAmelCase__     :    Optional[int]					  =      True
			lowerCAmelCase__     :    Optional[Any]					  =      True
			lowerCAmelCase__     :    List[str]					  =      True
			lowerCAmelCase__     :    Optional[Any]					  =      True
			lowerCAmelCase__     :    Tuple					  =      99
			lowerCAmelCase__     :    Optional[Any]					  =      16
			lowerCAmelCase__     :    str					  =      32
			lowerCAmelCase__     :    List[str]					  =      2
			lowerCAmelCase__     :    List[str]					  =      4
			lowerCAmelCase__     :    Union[str, Any]					  =      37
			lowerCAmelCase__     :    Tuple					  =      '''gelu'''
			lowerCAmelCase__     :    Any					  =      0.1
			lowerCAmelCase__     :    Optional[Any]					  =      0.1
			lowerCAmelCase__     :    Tuple					  =      512
			lowerCAmelCase__     :    int					  =      16
			lowerCAmelCase__     :    Tuple					  =      2
			lowerCAmelCase__     :    List[str]					  =      0.02
			lowerCAmelCase__     :    Tuple					  =      3
			lowerCAmelCase__     :    str					  =      4
			lowerCAmelCase__     :    Union[str, Any]					  =      None




	def 							UpperCAmelCase__(      self		:	List[str]	)-> Any:
			lowerCAmelCase__     :    str					  =      ids_tensor([self.batch_size, self.seq_length]	,      self.vocab_size	)

			lowerCAmelCase__     :    str					  =      None
			if self.use_input_mask:
					lowerCAmelCase__     :    Optional[int]					  =      random_attention_mask([self.batch_size, self.seq_length]	)

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

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

			lowerCAmelCase__     :    List[Any]					  =      AlbertConfig(
			    vocab_size=self.vocab_size	,      hidden_size=self.hidden_size	,      embedding_size=self.embedding_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	,      )

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




	def 							UpperCAmelCase__(      self		:	int	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]	,      _SCREAMING_SNAKE_CASE		:	str	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]	,      _SCREAMING_SNAKE_CASE		:	Any	,      _SCREAMING_SNAKE_CASE		:	List[Any]	,      _SCREAMING_SNAKE_CASE		:	List[Any]	)-> List[Any]:
			lowerCAmelCase__     :    int					  =      TFAlbertModel(config=_SCREAMING_SNAKE_CASE	)
			# inputs = {'input_ids': input_ids,
			#           'attention_mask': input_mask,
			#           'token_type_ids': token_type_ids}
			# sequence_output, pooled_output = model(**inputs)
			lowerCAmelCase__     :    str					  =      {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
			lowerCAmelCase__     :    Any					  =      model(_SCREAMING_SNAKE_CASE	)

			lowerCAmelCase__     :    str					  =      [input_ids, input_mask]
			lowerCAmelCase__     :    Optional[Any]					  =      model(_SCREAMING_SNAKE_CASE	)

			lowerCAmelCase__     :    str					  =      model(_SCREAMING_SNAKE_CASE	)

			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 							UpperCAmelCase__(      self		:	Optional[int]	,      _SCREAMING_SNAKE_CASE		:	Tuple	,      _SCREAMING_SNAKE_CASE		:	Optional[int]	,      _SCREAMING_SNAKE_CASE		:	int	,      _SCREAMING_SNAKE_CASE		:	int	,      _SCREAMING_SNAKE_CASE		:	Dict	,      _SCREAMING_SNAKE_CASE		:	List[Any]	,      _SCREAMING_SNAKE_CASE		:	Tuple	)-> Optional[Any]:
			lowerCAmelCase__     :    Any					  =      self.num_labels
			lowerCAmelCase__     :    Dict					  =      TFAlbertForPreTraining(config=_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    Tuple					  =      {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
			lowerCAmelCase__     :    Any					  =      model(_SCREAMING_SNAKE_CASE	)
			self.parent.assertEqual(result.prediction_logits.shape	,      (self.batch_size, self.seq_length, self.vocab_size)	)
			self.parent.assertEqual(result.sop_logits.shape	,      (self.batch_size, self.num_labels)	)




	def 							UpperCAmelCase__(      self		:	Optional[Any]	,      _SCREAMING_SNAKE_CASE		:	int	,      _SCREAMING_SNAKE_CASE		:	List[str]	,      _SCREAMING_SNAKE_CASE		:	Any	,      _SCREAMING_SNAKE_CASE		:	List[str]	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]	,      _SCREAMING_SNAKE_CASE		:	Optional[int]	,      _SCREAMING_SNAKE_CASE		:	Any	)-> Optional[int]:
			lowerCAmelCase__     :    Any					  =      TFAlbertForMaskedLM(config=_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    Any					  =      {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
			lowerCAmelCase__     :    Dict					  =      model(_SCREAMING_SNAKE_CASE	)
			self.parent.assertEqual(result.logits.shape	,      (self.batch_size, self.seq_length, self.vocab_size)	)




	def 							UpperCAmelCase__(      self		:	Optional[Any]	,      _SCREAMING_SNAKE_CASE		:	Tuple	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]	,      _SCREAMING_SNAKE_CASE		:	Any	,      _SCREAMING_SNAKE_CASE		:	str	,      _SCREAMING_SNAKE_CASE		:	int	,      _SCREAMING_SNAKE_CASE		:	Optional[int]	,      _SCREAMING_SNAKE_CASE		:	Any	)-> List[str]:
			lowerCAmelCase__     :    Union[str, Any]					  =      self.num_labels
			lowerCAmelCase__     :    List[str]					  =      TFAlbertForSequenceClassification(config=_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    str					  =      {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
			lowerCAmelCase__     :    int					  =      model(_SCREAMING_SNAKE_CASE	)
			self.parent.assertEqual(result.logits.shape	,      (self.batch_size, self.num_labels)	)




	def 							UpperCAmelCase__(      self		:	Dict	,      _SCREAMING_SNAKE_CASE		:	Optional[int]	,      _SCREAMING_SNAKE_CASE		:	List[Any]	,      _SCREAMING_SNAKE_CASE		:	str	,      _SCREAMING_SNAKE_CASE		:	List[Any]	,      _SCREAMING_SNAKE_CASE		:	int	,      _SCREAMING_SNAKE_CASE		:	List[str]	,      _SCREAMING_SNAKE_CASE		:	Optional[int]	)-> int:
			lowerCAmelCase__     :    List[str]					  =      TFAlbertForQuestionAnswering(config=_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    List[str]					  =      {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
			lowerCAmelCase__     :    Optional[Any]					  =      model(_SCREAMING_SNAKE_CASE	)
			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 							UpperCAmelCase__(      self		:	Tuple	,      _SCREAMING_SNAKE_CASE		:	List[Any]	,      _SCREAMING_SNAKE_CASE		:	int	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]	,      _SCREAMING_SNAKE_CASE		:	str	,      _SCREAMING_SNAKE_CASE		:	Any	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]	,      _SCREAMING_SNAKE_CASE		:	int	)-> str:
			lowerCAmelCase__     :    str					  =      self.num_choices
			lowerCAmelCase__     :    Tuple					  =      TFAlbertForMultipleChoice(config=_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    Union[str, Any]					  =      tf.tile(tf.expand_dims(_SCREAMING_SNAKE_CASE	,      1	)	,      (1, self.num_choices, 1)	)
			lowerCAmelCase__     :    Dict					  =      tf.tile(tf.expand_dims(_SCREAMING_SNAKE_CASE	,      1	)	,      (1, self.num_choices, 1)	)
			lowerCAmelCase__     :    Tuple					  =      tf.tile(tf.expand_dims(_SCREAMING_SNAKE_CASE	,      1	)	,      (1, self.num_choices, 1)	)
			lowerCAmelCase__     :    Tuple					  =      {
			    '''input_ids''': multiple_choice_inputs_ids,
			    '''attention_mask''': multiple_choice_input_mask,
			    '''token_type_ids''': multiple_choice_token_type_ids,
			}
			lowerCAmelCase__     :    Optional[Any]					  =      model(_SCREAMING_SNAKE_CASE	)
			self.parent.assertListEqual(list(result['''logits'''].shape	)	,      [self.batch_size, self.num_choices]	)




	def 							UpperCAmelCase__(      self		:	List[Any]	,      _SCREAMING_SNAKE_CASE		:	Tuple	,      _SCREAMING_SNAKE_CASE		:	Optional[int]	,      _SCREAMING_SNAKE_CASE		:	List[str]	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]	,      _SCREAMING_SNAKE_CASE		:	int	,      _SCREAMING_SNAKE_CASE		:	List[str]	)-> Tuple:
			lowerCAmelCase__     :    Union[str, Any]					  =      self.num_labels
			lowerCAmelCase__     :    Optional[int]					  =      TFAlbertForTokenClassification(config=_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    Any					  =      {
			    '''input_ids''': input_ids,
			    '''attention_mask''': input_mask,
			    '''token_type_ids''': token_type_ids,
			}
			lowerCAmelCase__     :    Optional[Any]					  =      model(_SCREAMING_SNAKE_CASE	)
			self.parent.assertListEqual(list(result['''logits'''].shape	)	,      [self.batch_size, self.seq_length, self.num_labels]	)




	def 							UpperCAmelCase__(      self		:	Union[str, Any]	)-> Dict:
			lowerCAmelCase__     :    int					  =      self.prepare_config_and_inputs()
			(
			    (
			    lowerCAmelCase__
			)  ,			(
			    lowerCAmelCase__
			)  ,			(
			    lowerCAmelCase__
			)  ,			(
			    lowerCAmelCase__
			)  ,			(
			    lowerCAmelCase__
			)  ,			(
			    lowerCAmelCase__
			)  ,			(
			    lowerCAmelCase__
			)  ,			
			)     :    Union[str, Any]					  =      config_and_inputs
			lowerCAmelCase__     :    Tuple					  =      {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
			return config, inputs_dict





@require_tf
class       _a							(       _lowercase  ,		_lowercase  ,		unittest.TestCase):
	_a						:						Tuple   					=							(
	    (
	        TFAlbertModel,
	        TFAlbertForPreTraining,
	        TFAlbertForMaskedLM,
	        TFAlbertForSequenceClassification,
	        TFAlbertForQuestionAnswering,
	        TFAlbertForTokenClassification,
	        TFAlbertForMultipleChoice,
	    )
	    if is_tf_available()
	    else ()
	)
	_a						:						Optional[Any]   					=							(
	    {
	        '''feature-extraction''': TFAlbertModel,
	        '''fill-mask''': TFAlbertForMaskedLM,
	        '''question-answering''': TFAlbertForQuestionAnswering,
	        '''text-classification''': TFAlbertForSequenceClassification,
	        '''token-classification''': TFAlbertForTokenClassification,
	        '''zero-shot''': TFAlbertForSequenceClassification,
	    }
	    if is_tf_available()
	    else {}
	)
	_a						:						Union[str, Any]   					=							False
	_a						:						int   					=							False




	def 							UpperCAmelCase__(      self		:	Any	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]	,      _SCREAMING_SNAKE_CASE		:	Any	,      _SCREAMING_SNAKE_CASE		:	List[str]=False	)-> Union[str, Any]:
			lowerCAmelCase__     :    Any					  =      super()._prepare_for_class(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	,      return_labels=_SCREAMING_SNAKE_CASE	)

			if return_labels:
					if model_class in get_values(_SCREAMING_SNAKE_CASE	):
							lowerCAmelCase__     :    Optional[Any]					  =      tf.zeros(self.model_tester.batch_size	,      dtype=tf.intaa	)

			return inputs_dict




	def 							UpperCAmelCase__(      self		:	List[str]	)-> Tuple:
			lowerCAmelCase__     :    List[Any]					  =      TFAlbertModelTester(self	)
			lowerCAmelCase__     :    List[Any]					  =      ConfigTester(self	,      config_class=_SCREAMING_SNAKE_CASE	,      hidden_size=37	)




	def 							UpperCAmelCase__(      self		:	str	)-> Any:
			self.config_tester.run_common_tests()




	def 							UpperCAmelCase__(      self		:	Optional[Any]	)-> Dict:
			lowerCAmelCase__     :    Any					  =      self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_albert_model(*_SCREAMING_SNAKE_CASE	)




	def 							UpperCAmelCase__(      self		:	Any	)-> str:
			lowerCAmelCase__     :    Any					  =      self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_albert_for_pretraining(*_SCREAMING_SNAKE_CASE	)




	def 							UpperCAmelCase__(      self		:	Optional[Any]	)-> str:
			lowerCAmelCase__     :    List[str]					  =      self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_albert_for_masked_lm(*_SCREAMING_SNAKE_CASE	)




	def 							UpperCAmelCase__(      self		:	Union[str, Any]	)-> Union[str, Any]:
			lowerCAmelCase__     :    int					  =      self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_albert_for_multiple_choice(*_SCREAMING_SNAKE_CASE	)




	def 							UpperCAmelCase__(      self		:	List[Any]	)-> List[str]:
			lowerCAmelCase__     :    Union[str, Any]					  =      self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_albert_for_sequence_classification(*_SCREAMING_SNAKE_CASE	)




	def 							UpperCAmelCase__(      self		:	str	)-> List[str]:
			lowerCAmelCase__     :    Dict					  =      self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_albert_for_question_answering(*_SCREAMING_SNAKE_CASE	)




	@slow
	def 							UpperCAmelCase__(      self		:	str	)-> Optional[int]:
			for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
					lowerCAmelCase__     :    Optional[int]					  =      TFAlbertModel.from_pretrained(_SCREAMING_SNAKE_CASE	)
					self.assertIsNotNone(_SCREAMING_SNAKE_CASE	)





@require_tf
class       _a							(       unittest.TestCase):




	@slow
	def 							UpperCAmelCase__(      self		:	str	)-> str:
			lowerCAmelCase__     :    Tuple					  =      TFAlbertForPreTraining.from_pretrained('''albert-base-v2'''	)
			lowerCAmelCase__     :    Tuple					  =      tf.constant([[0, 1, 2, 3, 4, 5]]	)
			lowerCAmelCase__     :    List[str]					  =      model(_SCREAMING_SNAKE_CASE	)[0]

			lowerCAmelCase__     :    Union[str, Any]					  =      [1, 6, 3_0000]
			self.assertEqual(output.shape	,      _SCREAMING_SNAKE_CASE	)

			lowerCAmelCase__     :    int					  =      tf.constant(
			    [
			        [
			            [4.59_5668, 0.7446_2754, -1.81_8147],
			            [4.595_4347, 0.745_4184, -1.818_8258],
			            [4.595_4905, 0.744_8235, -1.818_2316],
			        ]
			    ]	)
			tf.debugging.assert_near(output[:, :3, :3]	,      _SCREAMING_SNAKE_CASE	,      atol=1E-4	)




