

'''simple docstring'''





import uuid
from typing import Any, Dict, List, Optional, Union

from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_tf_available():
							import tensorflow as tf

if is_torch_available():
							import torch


UpperCamelCase_    						=       logging.get_logger(__name__)





class 		__SCREAMING_SNAKE_CASE							:







				def __init__(       self     :		Optional[Any]		,					UpperCAmelCase__     :		str = None		,					UpperCAmelCase__     :		uuid.UUID = None		,					UpperCAmelCase__     :		str=None		,					UpperCAmelCase__     :		int=None   ):
										'''simple docstring'''
										if not conversation_id:
																lowercase :							Any    		=uuid.uuida()
										if past_user_inputs is None:
																lowercase :							List[Any]    		=[]
										if generated_responses is None:
																lowercase :							Dict    		=[]

										lowercase :							uuid.UUID    		=conversation_id
										lowercase :							List[str]    		=past_user_inputs
										lowercase :							List[str]    		=generated_responses
										lowercase :							Optional[str]    		=text







				def __eq__(       self     :		Union[str, Any]		,					UpperCAmelCase__     :		Tuple   ):
										'''simple docstring'''
										if not isinstance(UpperCAmelCase__		,					UpperCAmelCase__   ):
																return False
										if self.uuid == other.uuid:
																return True
										return (
										    self.new_user_input == other.new_user_input
										    and self.past_user_inputs == other.past_user_inputs
										    and self.generated_responses == other.generated_responses
										)







				def  lowerCamelCase_	(       self     :		str		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		bool = False   ):
										'''simple docstring'''
										if self.new_user_input:
																if overwrite:
																						logger.warning(
																						    F'''User input added while unprocessed input was existing: "{self.new_user_input}" was overwritten '''
																						    F'''with: "{text}".'''   )
																						lowercase :							List[str]    		=text
																else:
																						logger.warning(
																						    F'''User input added while unprocessed input was existing: "{self.new_user_input}" new input '''
																						    F'''ignored: "{text}". Set `overwrite` to True to overwrite unprocessed user input'''   )
										else:
																lowercase :							List[Any]    		=text







				def  lowerCamelCase_	(       self     :		List[Any]   ):
										'''simple docstring'''
										if self.new_user_input:
																self.past_user_inputs.append(self.new_user_input   )
										lowercase :							List[Any]    		=None







				def  lowerCamelCase_	(       self     :		List[Any]		,					UpperCAmelCase__     :		str   ):
										'''simple docstring'''
										self.generated_responses.append(UpperCAmelCase__   )







				def  lowerCamelCase_	(       self     :		str   ):
										'''simple docstring'''
										for user_input, generated_response in zip(self.past_user_inputs		,					self.generated_responses   ):
																yield True, user_input
																yield False, generated_response
										if self.new_user_input:
																yield True, self.new_user_input







				def __repr__(       self     :		int   ):
										'''simple docstring'''
										lowercase :							str    		=F'''Conversation id: {self.uuid} \n'''
										for is_user, text in self.iter_texts():
																lowercase :							List[str]    		='''user''' if is_user else '''bot'''
																output += F'''{name} >> {text} \n'''
										return output





@add_end_docstrings(
    lowercase__						,							R'\n        min_length_for_response (`int`, *optional*, defaults to 32):\n            The minimum length (in number of tokens) for a response.\n        minimum_tokens (`int`, *optional*, defaults to 10):\n            The minimum length of tokens to leave for a response.\n    '						,							)
class 		__SCREAMING_SNAKE_CASE							(			lowercase__      ):







				def __init__(       self     :		Union[str, Any]		,					*UpperCAmelCase__     :		Any		,					**UpperCAmelCase__     :		str   ):
										'''simple docstring'''
										super().__init__(*UpperCAmelCase__		,					**UpperCAmelCase__   )
										if self.tokenizer.pad_token_id is None:
																lowercase :							Tuple    		=self.tokenizer.eos_token







				def  lowerCamelCase_	(       self     :		Tuple		,					UpperCAmelCase__     :		Tuple=None		,					UpperCAmelCase__     :		Optional[Any]=None		,					UpperCAmelCase__     :		Any=None		,					**UpperCAmelCase__     :		Union[str, Any]   ):
										'''simple docstring'''
										lowercase :							Tuple    		={}
										lowercase :							Tuple    		={}
										lowercase :							Dict    		={}

										if min_length_for_response is not None:
																lowercase :							List[str]    		=min_length_for_response
										if minimum_tokens is not None:
																lowercase :							Optional[Any]    		=minimum_tokens

										if "max_length" in generate_kwargs:
																lowercase :							List[str]    		=generate_kwargs['''max_length''']
																# self.max_length = generate_kwargs.get("max_length", self.model.config.max_length)
										if clean_up_tokenization_spaces is not None:
																lowercase :							Optional[Any]    		=clean_up_tokenization_spaces

										if generate_kwargs:
																forward_params.update(UpperCAmelCase__   )
										return preprocess_params, forward_params, postprocess_params







				def __call__(       self     :		str		,					UpperCAmelCase__     :		Union[Conversation, List[Conversation]]		,					UpperCAmelCase__     :		Any=0		,					**UpperCAmelCase__     :		Any   ):
										'''simple docstring'''
										lowercase :							List[Any]    		=super().__call__(UpperCAmelCase__		,					num_workers=UpperCAmelCase__		,					**UpperCAmelCase__   )
										if isinstance(UpperCAmelCase__		,					UpperCAmelCase__   ) and len(UpperCAmelCase__   ) == 1:
																return outputs[0]
										return outputs







				def  lowerCamelCase_	(       self     :		List[Any]		,					UpperCAmelCase__     :		Conversation		,					UpperCAmelCase__     :		Any=32   ):
										'''simple docstring'''
										if not isinstance(UpperCAmelCase__		,					UpperCAmelCase__   ):
																raise ValueError('''ConversationalPipeline, expects Conversation as inputs'''   )
										if conversation.new_user_input is None:
																raise ValueError(
																    F'''Conversation with UUID {type(conversation.uuid   )} does not contain new user input to process. '''
																    '''Add user inputs with the conversation\'s `add_user_input` method'''   )
										if hasattr(self.tokenizer		,					'''_build_conversation_input_ids'''   ):
																lowercase :							Optional[int]    		=self.tokenizer._build_conversation_input_ids(UpperCAmelCase__   )
										else:
																# If the tokenizer cannot handle conversations, we default to only the old version
																lowercase :							Any    		=self._legacy_parse_and_tokenize(UpperCAmelCase__   )

										if self.framework == "pt":
																lowercase :							int    		=torch.LongTensor([input_ids]   )
										elif self.framework == "tf":
																lowercase :							int    		=tf.constant([input_ids]   )
										return {"input_ids": input_ids, "conversation": conversation}







				def  lowerCamelCase_	(       self     :		List[str]		,					UpperCAmelCase__     :		Optional[int]		,					UpperCAmelCase__     :		int=10		,					**UpperCAmelCase__     :		Tuple   ):
										'''simple docstring'''
										lowercase :							Union[str, Any]    		=generate_kwargs.get('''max_length'''		,					self.model.config.max_length   )

										lowercase :							List[str]    		=model_inputs['''input_ids'''].shape[1]
										if max_length - minimum_tokens < n:
																logger.warning(F'''Conversation input is to long ({n}), trimming it to ({max_length} - {minimum_tokens})'''   )
																lowercase :							Dict    		=max_length - minimum_tokens
																lowercase :							Any    		=model_inputs['''input_ids'''][:, -trim:]
																if "attention_mask" in model_inputs:
																						lowercase :							Tuple    		=model_inputs['''attention_mask'''][:, -trim:]
										lowercase :							int    		=model_inputs.pop('''conversation'''   )
										lowercase :							Any    		=max_length
										lowercase :							Any    		=self.model.generate(**UpperCAmelCase__		,					**UpperCAmelCase__   )
										if self.model.config.is_encoder_decoder:
																lowercase :							int    		=1
										else:
																lowercase :							List[str]    		=n
										return {"output_ids": output_ids[:, start_position:], "conversation": conversation}







				def  lowerCamelCase_	(       self     :		Dict		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		List[Any]=True   ):
										'''simple docstring'''
										lowercase :							Optional[int]    		=model_outputs['''output_ids''']
										lowercase :							int    		=self.tokenizer.decode(
										    output_ids[0]		,					skip_special_tokens=UpperCAmelCase__		,					clean_up_tokenization_spaces=UpperCAmelCase__		,					)
										lowercase :							Optional[Any]    		=model_outputs['''conversation''']
										conversation.mark_processed()
										conversation.append_response(UpperCAmelCase__   )
										return conversation







				def  lowerCamelCase_	(       self     :		Any		,					UpperCAmelCase__     :		Conversation   ):
										'''simple docstring'''
										lowercase :							Optional[int]    		=self.tokenizer.eos_token_id
										lowercase :							List[Any]    		=[]
										for is_user, text in conversation.iter_texts():
																if eos_token_id is not None:
																						input_ids.extend(self.tokenizer.encode(UpperCAmelCase__		,					add_special_tokens=UpperCAmelCase__   ) + [eos_token_id]   )
																else:
																						input_ids.extend(self.tokenizer.encode(UpperCAmelCase__		,					add_special_tokens=UpperCAmelCase__   )   )

										if len(UpperCAmelCase__   ) > self.tokenizer.model_max_length:
																lowercase :							Optional[Any]    		=input_ids[-self.tokenizer.model_max_length :]
										return input_ids








'''simple docstring'''





import unittest

from transformers import AlbertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
							import torch

							from transformers import (
							    MODEL_FOR_PRETRAINING_MAPPING,
							    AlbertForMaskedLM,
							    AlbertForMultipleChoice,
							    AlbertForPreTraining,
							    AlbertForQuestionAnswering,
							    AlbertForSequenceClassification,
							    AlbertForTokenClassification,
							    AlbertModel,
							)
							from transformers.models.albert.modeling_albert import ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST





class 		__SCREAMING_SNAKE_CASE							:







				def __init__(       self     :		Dict		,					UpperCAmelCase__     :		List[Any]		,					UpperCAmelCase__     :		str=13		,					UpperCAmelCase__     :		Tuple=7		,					UpperCAmelCase__     :		Dict=True		,					UpperCAmelCase__     :		Optional[int]=True		,					UpperCAmelCase__     :		Union[str, Any]=True		,					UpperCAmelCase__     :		Tuple=True		,					UpperCAmelCase__     :		Optional[Any]=99		,					UpperCAmelCase__     :		Any=16		,					UpperCAmelCase__     :		Optional[Any]=36		,					UpperCAmelCase__     :		str=6		,					UpperCAmelCase__     :		Any=6		,					UpperCAmelCase__     :		Optional[int]=6		,					UpperCAmelCase__     :		Any=37		,					UpperCAmelCase__     :		List[str]="gelu"		,					UpperCAmelCase__     :		Union[str, Any]=0.1		,					UpperCAmelCase__     :		Optional[int]=0.1		,					UpperCAmelCase__     :		List[str]=512		,					UpperCAmelCase__     :		List[str]=16		,					UpperCAmelCase__     :		Optional[int]=2		,					UpperCAmelCase__     :		Any=0.02		,					UpperCAmelCase__     :		Union[str, Any]=3		,					UpperCAmelCase__     :		List[Any]=4		,					UpperCAmelCase__     :		Tuple=None		,					):
										'''simple docstring'''
										lowercase :							str    		=parent
										lowercase :							int    		=batch_size
										lowercase :							Any    		=seq_length
										lowercase :							int    		=is_training
										lowercase :							str    		=use_input_mask
										lowercase :							int    		=use_token_type_ids
										lowercase :							Dict    		=use_labels
										lowercase :							int    		=vocab_size
										lowercase :							str    		=embedding_size
										lowercase :							Union[str, Any]    		=hidden_size
										lowercase :							Tuple    		=num_hidden_layers
										lowercase :							Any    		=num_hidden_groups
										lowercase :							Union[str, Any]    		=num_attention_heads
										lowercase :							Any    		=intermediate_size
										lowercase :							Tuple    		=hidden_act
										lowercase :							Optional[int]    		=hidden_dropout_prob
										lowercase :							Union[str, Any]    		=attention_probs_dropout_prob
										lowercase :							List[Any]    		=max_position_embeddings
										lowercase :							int    		=type_vocab_size
										lowercase :							int    		=type_sequence_label_size
										lowercase :							Any    		=initializer_range
										lowercase :							List[Any]    		=num_labels
										lowercase :							int    		=num_choices
										lowercase :							Optional[int]    		=scope







				def  lowerCamelCase_	(       self     :		Union[str, Any]   ):
										'''simple docstring'''
										lowercase :							int    		=ids_tensor([self.batch_size, self.seq_length]		,					self.vocab_size   )

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

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

										lowercase :							Tuple    		=None
										lowercase :							Any    		=None
										lowercase :							Dict    		=None
										if self.use_labels:
																lowercase :							int    		=ids_tensor([self.batch_size]		,					self.type_sequence_label_size   )
																lowercase :							str    		=ids_tensor([self.batch_size, self.seq_length]		,					self.num_labels   )
																lowercase :							Optional[Any]    		=ids_tensor([self.batch_size]		,					self.num_choices   )

										lowercase :							Any    		=self.get_config()

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







				def  lowerCamelCase_	(       self     :		Union[str, Any]   ):
										'''simple docstring'''
										return AlbertConfig(
										    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		,					num_hidden_groups=self.num_hidden_groups		,					)







				def  lowerCamelCase_	(       self     :		Union[str, Any]		,					UpperCAmelCase__     :		List[Any]		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		Any		,					UpperCAmelCase__     :		List[str]		,					UpperCAmelCase__     :		Dict		,					UpperCAmelCase__     :		Optional[Any]		,					UpperCAmelCase__     :		str   ):
										'''simple docstring'''
										lowercase :							int    		=AlbertModel(config=UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							int    		=model(UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					token_type_ids=UpperCAmelCase__   )
										lowercase :							Dict    		=model(UpperCAmelCase__		,					token_type_ids=UpperCAmelCase__   )
										lowercase :							int    		=model(UpperCAmelCase__   )
										self.parent.assertEqual(result.last_hidden_state.shape		,					(self.batch_size, self.seq_length, self.hidden_size)   )
										self.parent.assertEqual(result.pooler_output.shape		,					(self.batch_size, self.hidden_size)   )







				def  lowerCamelCase_	(       self     :		Optional[Any]		,					UpperCAmelCase__     :		Dict		,					UpperCAmelCase__     :		Optional[int]		,					UpperCAmelCase__     :		Any		,					UpperCAmelCase__     :		Dict		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		Dict		,					UpperCAmelCase__     :		Tuple   ):
										'''simple docstring'''
										lowercase :							Tuple    		=AlbertForPreTraining(config=UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							int    		=model(
										    UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					token_type_ids=UpperCAmelCase__		,					labels=UpperCAmelCase__		,					sentence_order_label=UpperCAmelCase__		,					)
										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, config.num_labels)   )







				def  lowerCamelCase_	(       self     :		List[Any]		,					UpperCAmelCase__     :		Optional[Any]		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		Dict		,					UpperCAmelCase__     :		Tuple		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		Optional[int]		,					UpperCAmelCase__     :		int   ):
										'''simple docstring'''
										lowercase :							Tuple    		=AlbertForMaskedLM(config=UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							str    		=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  lowerCamelCase_	(       self     :		Any		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		Dict		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		List[Any]		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		Union[str, Any]   ):
										'''simple docstring'''
										lowercase :							List[str]    		=AlbertForQuestionAnswering(config=UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							List[str]    		=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  lowerCamelCase_	(       self     :		List[str]		,					UpperCAmelCase__     :		List[Any]		,					UpperCAmelCase__     :		Union[str, Any]		,					UpperCAmelCase__     :		Dict		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		List[str]		,					UpperCAmelCase__     :		Union[str, Any]   ):
										'''simple docstring'''
										lowercase :							Optional[Any]    		=self.num_labels
										lowercase :							Any    		=AlbertForSequenceClassification(UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							Dict    		=model(UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					token_type_ids=UpperCAmelCase__		,					labels=UpperCAmelCase__   )
										self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.num_labels)   )







				def  lowerCamelCase_	(       self     :		Optional[int]		,					UpperCAmelCase__     :		List[str]		,					UpperCAmelCase__     :		Optional[Any]		,					UpperCAmelCase__     :		Optional[int]		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		Any		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		Dict   ):
										'''simple docstring'''
										lowercase :							List[Any]    		=self.num_labels
										lowercase :							str    		=AlbertForTokenClassification(config=UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							int    		=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  lowerCamelCase_	(       self     :		List[str]		,					UpperCAmelCase__     :		Optional[int]		,					UpperCAmelCase__     :		Union[str, Any]		,					UpperCAmelCase__     :		Dict		,					UpperCAmelCase__     :		List[str]		,					UpperCAmelCase__     :		Tuple		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		List[str]   ):
										'''simple docstring'''
										lowercase :							Optional[int]    		=self.num_choices
										lowercase :							List[Any]    		=AlbertForMultipleChoice(config=UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							List[Any]    		=input_ids.unsqueeze(1   ).expand(-1		,					self.num_choices		,					-1   ).contiguous()
										lowercase :							int    		=token_type_ids.unsqueeze(1   ).expand(-1		,					self.num_choices		,					-1   ).contiguous()
										lowercase :							int    		=input_mask.unsqueeze(1   ).expand(-1		,					self.num_choices		,					-1   ).contiguous()
										lowercase :							List[str]    		=model(
										    UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					token_type_ids=UpperCAmelCase__		,					labels=UpperCAmelCase__		,					)
										self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.num_choices)   )







				def  lowerCamelCase_	(       self     :		int   ):
										'''simple docstring'''
										lowercase :							Union[str, Any]    		=self.prepare_config_and_inputs()
										(
										    (
										    lowercase
										)		,	(
										    lowercase
										)		,	(
										    lowercase
										)		,	(
										    lowercase
										)		,	(
										    lowercase
										)		,	(
										    lowercase
										)		,	(
										    lowercase
										)		,	
										) :							Dict    		=config_and_inputs
										lowercase :							Optional[Any]    		={'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
										return config, inputs_dict





@require_torch
class 		__SCREAMING_SNAKE_CASE							(			lowercase__						,							lowercase__						,							unittest.TestCase      ):
				lowerCamelCase_		       =    (
				    (
				        AlbertModel,
				        AlbertForPreTraining,
				        AlbertForMaskedLM,
				        AlbertForMultipleChoice,
				        AlbertForSequenceClassification,
				        AlbertForTokenClassification,
				        AlbertForQuestionAnswering,
				    )
				    if is_torch_available()
				    else ()
				)
				lowerCamelCase_		       =    (
				    {
				        'feature-extraction': AlbertModel,
				        'fill-mask': AlbertForMaskedLM,
				        'question-answering': AlbertForQuestionAnswering,
				        'text-classification': AlbertForSequenceClassification,
				        'token-classification': AlbertForTokenClassification,
				        'zero-shot': AlbertForSequenceClassification,
				    }
				    if is_torch_available()
				    else {}
				)
				lowerCamelCase_		       =    True







				def  lowerCamelCase_	(       self     :		List[str]		,					UpperCAmelCase__     :		Any		,					UpperCAmelCase__     :		Tuple		,					UpperCAmelCase__     :		int=False   ):
										'''simple docstring'''
										lowercase :							Optional[int]    		=super()._prepare_for_class(UpperCAmelCase__		,					UpperCAmelCase__		,					return_labels=UpperCAmelCase__   )

										if return_labels:
																if model_class in get_values(UpperCAmelCase__   ):
																						lowercase :							Any    		=torch.zeros(
																						    (self.model_tester.batch_size, self.model_tester.seq_length)		,					dtype=torch.long		,					device=UpperCAmelCase__   )
																						lowercase :							Any    		=torch.zeros(
																						    self.model_tester.batch_size		,					dtype=torch.long		,					device=UpperCAmelCase__   )
										return inputs_dict







				def  lowerCamelCase_	(       self     :		Union[str, Any]   ):
										'''simple docstring'''
										lowercase :							Tuple    		=AlbertModelTester(self   )
										lowercase :							Optional[Any]    		=ConfigTester(self		,					config_class=UpperCAmelCase__		,					hidden_size=37   )







				def  lowerCamelCase_	(       self     :		List[str]   ):
										'''simple docstring'''
										self.config_tester.run_common_tests()







				def  lowerCamelCase_	(       self     :		Tuple   ):
										'''simple docstring'''
										lowercase :							Optional[Any]    		=self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*UpperCAmelCase__   )







				def  lowerCamelCase_	(       self     :		List[str]   ):
										'''simple docstring'''
										lowercase :							Dict    		=self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_pretraining(*UpperCAmelCase__   )







				def  lowerCamelCase_	(       self     :		Dict   ):
										'''simple docstring'''
										lowercase :							Dict    		=self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_masked_lm(*UpperCAmelCase__   )







				def  lowerCamelCase_	(       self     :		str   ):
										'''simple docstring'''
										lowercase :							List[Any]    		=self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_multiple_choice(*UpperCAmelCase__   )







				def  lowerCamelCase_	(       self     :		int   ):
										'''simple docstring'''
										lowercase :							str    		=self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_question_answering(*UpperCAmelCase__   )







				def  lowerCamelCase_	(       self     :		Optional[int]   ):
										'''simple docstring'''
										lowercase :							int    		=self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_sequence_classification(*UpperCAmelCase__   )







				def  lowerCamelCase_	(       self     :		List[Any]   ):
										'''simple docstring'''
										lowercase :							Optional[int]    		=self.model_tester.prepare_config_and_inputs()
										for type in ["absolute", "relative_key", "relative_key_query"]:
																lowercase :							Tuple    		=type
																self.model_tester.create_and_check_model(*UpperCAmelCase__   )







				@slow
				def  lowerCamelCase_	(       self     :		Optional[Any]   ):
										'''simple docstring'''
										for model_name in ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																lowercase :							str    		=AlbertModel.from_pretrained(UpperCAmelCase__   )
																self.assertIsNotNone(UpperCAmelCase__   )





@require_torch
class 		__SCREAMING_SNAKE_CASE							(			unittest.TestCase      ):







				@slow
				def  lowerCamelCase_	(       self     :		Tuple   ):
										'''simple docstring'''
										lowercase :							int    		=AlbertModel.from_pretrained('''albert-base-v2'''   )
										lowercase :							Optional[int]    		=torch.tensor([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]   )
										lowercase :							Any    		=torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]   )
										with torch.no_grad():
																lowercase :							Any    		=model(UpperCAmelCase__		,					attention_mask=UpperCAmelCase__   )[0]
										lowercase :							int    		=torch.Size((1, 11, 768)   )
										self.assertEqual(output.shape		,					UpperCAmelCase__   )
										lowercase :							Union[str, Any]    		=torch.tensor(
										    [[[-0.65_13, 1.50_35, -0.27_66], [-0.65_15, 1.50_46, -0.27_80], [-0.65_12, 1.50_49, -0.27_84]]]   )

										self.assertTrue(torch.allclose(output[:, 1:4, 1:4]		,					UpperCAmelCase__		,					atol=1E-4   )   )





