"""simple docstring"""







import math
import sys

class 						UpperCamelCase     :



				def __init__(self							: str)       ->      int:
					__snake_case     :				Tuple 						=					0
					__snake_case     :				int 						=					[]
					__snake_case     :				Dict 						=					{}  # To store the pos of node in array



				def    _lowercase	(self							: List[str])       ->      List[Any]:
					return self.cur_size == 0



				def    _lowercase	(self							: Optional[Any]      ,    _A							: Tuple)       ->      str:
					__snake_case     :				int 						=					self.left(lowercase__)
					__snake_case     :				Any 						=					self.right(lowercase__)
					if lc < self.cur_size and self.array(lowercase__)[0] < self.array(lowercase__)[0]:
						__snake_case     :				Optional[Any] 						=					lc
					else:
						__snake_case     :				Tuple 						=					idx
					if rc < self.cur_size and self.array(lowercase__)[0] < self.array(lowercase__)[0]:
						__snake_case     :				Tuple 						=					rc
					if smallest != idx:
						self.swap(lowercase__      ,    lowercase__)
						self.min_heapify(lowercase__)



				def    _lowercase	(self							: Dict      ,    _A							: List[str])       ->      Optional[Any]:
					# Inserts a node into the Priority Queue
					__snake_case     :				Optional[Any] 						=					self.cur_size
					self.cur_size += 1
					self.array.append((sys.maxsize, tup[1]))
					self.decrease_key((sys.maxsize, tup[1])      ,    tup[0])



				def    _lowercase	(self							: Dict)       ->      Optional[Any]:
					# Removes and returns the min element at top of priority queue
					__snake_case     :				Optional[int] 						=					self.array[0][1]
					__snake_case     :				List[Any] 						=					self.array[self.cur_size - 1]
					self.cur_size -= 1
					self.min_heapify(1)
					del self.pos[min_node]
					return min_node



				def    _lowercase	(self							: List[Any]      ,    _A							: Optional[Any])       ->      Optional[int]:
					# returns the index of left child
					return 2 * i + 1



				def    _lowercase	(self							: int      ,    _A							: Tuple)       ->      Dict:
					# returns the index of right child
					return 2 * i + 2



				def    _lowercase	(self							: Union[str, Any]      ,    _A							: Optional[Any])       ->      Union[str, Any]:
					# returns the index of parent
					return math.floor(i / 2)



				def    _lowercase	(self							: Dict      ,    _A							: Dict      ,    _A							: Dict)       ->      List[Any]:
					# swaps array elements at indices i and j
					# update the pos{}
					__snake_case     :				Optional[int] 						=					j
					__snake_case     :				Tuple 						=					i
					__snake_case     :				Optional[Any] 						=					self.array[i]
					__snake_case     :				Union[str, Any] 						=					self.array[j]
					__snake_case     :				Dict 						=					temp






				def    _lowercase	(self							: str      ,    _A							: Tuple      ,    _A							: Optional[int])       ->      Optional[Any]:
					__snake_case     :				Dict 						=					self.pos[tup[1]]
					# assuming the new_d is atmost old_d
					__snake_case     :				Dict 						=					(new_d, tup[1])
					while idx > 0 and self.array[self.par(lowercase__)][0] > self.array[idx][0]:
						self.swap(lowercase__      ,    self.par(lowercase__))
						__snake_case     :				List[Any] 						=					self.par(lowercase__)







class 						UpperCamelCase     :



				def __init__(self							: List[str]      ,    _A							: Tuple)       ->      Tuple:
					__snake_case     :				str 						=					{}  # To store graph: u -> (v,w)
					__snake_case     :				str 						=					num  # Number of nodes in graph
					# To store the distance from source vertex
					__snake_case     :				List[Any] 						=					[0] * self.num_nodes
					__snake_case     :				Tuple 						=					[-1] * self.num_nodes  # To store the path



				def    _lowercase	(self							: Tuple      ,    _A							: int      ,    _A							: Any      ,    _A							: Tuple)       ->      Tuple:
					#  Edge going from node u to v and v to u with weight w
					# u (w)-> v, v (w) -> u
					# Check if u already in graph
					if u in self.adjList:
						self.adjList[u].append((v, w))
					else:
						__snake_case     :				int 						=					[(v, w)]

					# Assuming undirected graph
					if v in self.adjList:
						self.adjList[v].append((u, w))
					else:
						__snake_case     :				Union[str, Any] 						=					[(u, w)]



				def    _lowercase	(self							: List[Any])       ->      Optional[Any]:
					# u -> v(w)
					for u in self.adjList:
						print(lowercase__      ,    '->'      ,    ' -> '.join(str(f"{v}({w})") for v, w in self.adjList[u]))



				def    _lowercase	(self							: Tuple      ,    _A							: List[Any])       ->      List[Any]:
					# Flush old junk values in par[]
					__snake_case     :				List[str] 						=					[-1] * self.num_nodes
					# src is the source node
					__snake_case     :				Union[str, Any] 						=					0
					__snake_case     :				Tuple 						=					PriorityQueue()
					q.insert((0, src))  # (dist from src, node)
					for u in self.adjList:
						if u != src:
							__snake_case     :				Union[str, Any] 						=					sys.maxsize  # Infinity
							__snake_case     :				Tuple 						=					-1

					while not q.is_empty():
						__snake_case     :				str 						=					q.extract_min()  # Returns node with the min dist from source
						# Update the distance of all the neighbours of u and
						# if their prev dist was INFINITY then push them in Q
						for v, w in self.adjList[u]:
							__snake_case     :				Optional[Any] 						=					self.dist[u] + w
							if self.dist[v] > new_dist:
								if self.dist[v] == sys.maxsize:
									q.insert((new_dist, v))
								else:
									q.decrease_key((self.dist[v], v)      ,    lowercase__)
								__snake_case     :				Union[str, Any] 						=					new_dist
								__snake_case     :				int 						=					u

        # Show the shortest distances from src
					self.show_distances(lowercase__)



				def    _lowercase	(self							: List[str]      ,    _A							: Any)       ->      Any:
					print(f"Distance from node: {src}")
					for u in range(self.num_nodes):
						print(f"Node {u} has distance: {self.dist[u]}")






				def    _lowercase	(self							: Dict      ,    _A							: List[str]      ,    _A							: List[Any])       ->      str:
					# To show the shortest path from src to dest
					# WARNING: Use it *after* calling dijkstra
					__snake_case     :				Optional[int] 						=					[]
					__snake_case     :				List[Any] 						=					0
					__snake_case     :				int 						=					dest
					# Backtracking from dest to src
					while self.par[temp] != -1:
						path.append(lowercase__)
						if temp != src:
							for v, w in self.adjList[temp]:
								if v == self.par[temp]:
									cost += w
									break
						__snake_case     :				Dict 						=					self.par[temp]
					path.append(lowercase__)
					path.reverse()

					print(f"----Path to reach {dest} from {src}----")
					for u in path:
						print(f"{u}"      ,    end=' ')
						if u != dest:
							print('-> '      ,    end='')

					print('\nTotal cost of path: '      ,    lowercase__)


if __name__ == "__main__":
	_a	:	Union[str, Any]=					Graph(9)
	graph.add_edge(0, 1, 4)
	graph.add_edge(0, 7, 8)
	graph.add_edge(1, 2, 8)
	graph.add_edge(1, 7, 11)
	graph.add_edge(2, 3, 7)
	graph.add_edge(2, 8, 2)
	graph.add_edge(2, 5, 4)
	graph.add_edge(3, 4, 9)
	graph.add_edge(3, 5, 14)
	graph.add_edge(4, 5, 10)
	graph.add_edge(5, 6, 2)
	graph.add_edge(6, 7, 1)
	graph.add_edge(6, 8, 6)
	graph.add_edge(7, 8, 7)
	graph.show_graph()
	graph.dijkstra(0)
	graph.show_path(0, 4)

# OUTPUT
# 0 -> 1(4) -> 7(8)
# 1 -> 0(4) -> 2(8) -> 7(11)
# 7 -> 0(8) -> 1(11) -> 6(1) -> 8(7)
# 2 -> 1(8) -> 3(7) -> 8(2) -> 5(4)
# 3 -> 2(7) -> 4(9) -> 5(14)
# 8 -> 2(2) -> 6(6) -> 7(7)
# 5 -> 2(4) -> 3(14) -> 4(10) -> 6(2)
# 4 -> 3(9) -> 5(10)
# 6 -> 5(2) -> 7(1) -> 8(6)
# Distance from node: 0
# Node 0 has distance: 0
# Node 1 has distance: 4
# Node 2 has distance: 12
# Node 3 has distance: 19
# Node 4 has distance: 21
# Node 5 has distance: 11
# Node 6 has distance: 9
# Node 7 has distance: 8
# Node 8 has distance: 14
# ----Path to reach 4 from 0----
# 0 -> 7 -> 6 -> 5 -> 4
# Total cost of path:  21











import unittest

from transformers import ElectraConfig, 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, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
  import torch

  from transformers import (
      MODEL_FOR_PRETRAINING_MAPPING,
      ElectraForCausalLM,
      ElectraForMaskedLM,
      ElectraForMultipleChoice,
      ElectraForPreTraining,
      ElectraForQuestionAnswering,
      ElectraForSequenceClassification,
      ElectraForTokenClassification,
      ElectraModel,
  )
  from transformers.models.electra.modeling_electra import ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST
class 							__lowercase   :



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



     def 				__magic_name__		(  self   :							str       ):
       a_		    =  ids_tensor([self.batch_size, self.seq_length]      ,		self.vocab_size       )

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

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

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

       a_		    =  self.get_config()

       return (
           config,
           input_ids,
           token_type_ids,
           input_mask,
           sequence_labels,
           token_labels,
           choice_labels,
           fake_token_labels,
       )



     def 				__magic_name__		(  self   :							Any       ):
       return ElectraConfig(
           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      ,		is_decoder=lowercase__      ,		initializer_range=self.initializer_range      ,		)



     def 				__magic_name__		(  self   :							Dict       ):
       (
           (
           a_
       )    , (
           a_
       )    , (
           a_
       )    , (
           a_
       )    , (
           a_
       )    , (
           a_
       )    , (
           a_
       )    , (
           a_
       )    , 
       )		    =  self.prepare_config_and_inputs()

       a_		    =  True
       a_		    =  floats_tensor([self.batch_size, self.seq_length, self.hidden_size]       )
       a_		    =  ids_tensor([self.batch_size, self.seq_length]      ,		vocab_size=2       )

       return (
           config,
           input_ids,
           token_type_ids,
           input_mask,
           sequence_labels,
           token_labels,
           choice_labels,
           encoder_hidden_states,
           encoder_attention_mask,
       )



     def 				__magic_name__		(  self   :							Union[str, Any]      ,		lowercase__   :							Optional[Any]      ,		lowercase__   :							int      ,		lowercase__   :							List[Any]      ,		lowercase__   :							List[Any]      ,		lowercase__   :							str      ,		lowercase__   :							Union[str, Any]      ,		lowercase__   :							str      ,		lowercase__   :							str      ,		):
       a_		    =  ElectraModel(config=lowercase__       )
       model.to(lowercase__       )
       model.eval()
       a_		    =  model(lowercase__      ,		attention_mask=lowercase__      ,		token_type_ids=lowercase__       )
       a_		    =  model(lowercase__      ,		token_type_ids=lowercase__       )
       a_		    =  model(lowercase__       )
       self.parent.assertEqual(result.last_hidden_state.shape      ,		(self.batch_size, self.seq_length, self.hidden_size)       )



     def 				__magic_name__		(  self   :							Optional[int]      ,		lowercase__   :							int      ,		lowercase__   :							Tuple      ,		lowercase__   :							Union[str, Any]      ,		lowercase__   :							Optional[Any]      ,		lowercase__   :							List[str]      ,		lowercase__   :							Optional[Any]      ,		lowercase__   :							Any      ,		lowercase__   :							Dict      ,		lowercase__   :							Optional[Any]      ,		):
       a_		    =  True
       a_		    =  ElectraModel(lowercase__       )
       model.to(lowercase__       )
       model.eval()
       a_		    =  model(
           lowercase__      ,		attention_mask=lowercase__      ,		token_type_ids=lowercase__      ,		encoder_hidden_states=lowercase__      ,		encoder_attention_mask=lowercase__      ,		)
       a_		    =  model(
           lowercase__      ,		attention_mask=lowercase__      ,		token_type_ids=lowercase__      ,		encoder_hidden_states=lowercase__      ,		)
       a_		    =  model(lowercase__      ,		attention_mask=lowercase__      ,		token_type_ids=lowercase__       )
       self.parent.assertEqual(result.last_hidden_state.shape      ,		(self.batch_size, self.seq_length, self.hidden_size)       )



     def 				__magic_name__		(  self   :							str      ,		lowercase__   :							List[Any]      ,		lowercase__   :							Any      ,		lowercase__   :							Union[str, Any]      ,		lowercase__   :							Tuple      ,		lowercase__   :							Union[str, Any]      ,		lowercase__   :							Any      ,		lowercase__   :							Dict      ,		lowercase__   :							Any      ,		):
       a_		    =  ElectraForMaskedLM(config=lowercase__       )
       model.to(lowercase__       )
       model.eval()
       a_		    =  model(lowercase__      ,		attention_mask=lowercase__      ,		token_type_ids=lowercase__      ,		labels=lowercase__       )
       self.parent.assertEqual(result.logits.shape      ,		(self.batch_size, self.seq_length, self.vocab_size)       )



     def 				__magic_name__		(  self   :							Optional[int]      ,		lowercase__   :							Dict      ,		lowercase__   :							Dict      ,		lowercase__   :							Dict      ,		lowercase__   :							str      ,		lowercase__   :							List[Any]      ,		lowercase__   :							List[str]      ,		lowercase__   :							Union[str, Any]      ,		lowercase__   :							int      ,		lowercase__   :							str      ,		):
       a_		    =  ElectraForCausalLM(config=lowercase__       )
       model.to(lowercase__       )
       model.eval()
       a_		    =  model(lowercase__      ,		attention_mask=lowercase__      ,		token_type_ids=lowercase__      ,		labels=lowercase__       )
       self.parent.assertEqual(result.logits.shape      ,		(self.batch_size, self.seq_length, self.vocab_size)       )



     def 				__magic_name__		(  self   :							str      ,		lowercase__   :							Union[str, Any]      ,		lowercase__   :							List[Any]      ,		lowercase__   :							str      ,		lowercase__   :							List[str]      ,		lowercase__   :							Union[str, Any]      ,		lowercase__   :							Dict      ,		lowercase__   :							Dict      ,		lowercase__   :							List[Any]      ,		):
       a_		    =  self.num_labels
       a_		    =  ElectraForTokenClassification(config=lowercase__       )
       model.to(lowercase__       )
       model.eval()
       a_		    =  model(lowercase__      ,		attention_mask=lowercase__      ,		token_type_ids=lowercase__      ,		labels=lowercase__       )
       self.parent.assertEqual(result.logits.shape      ,		(self.batch_size, self.seq_length, self.num_labels)       )



     def 				__magic_name__		(  self   :							Any      ,		lowercase__   :							Any      ,		lowercase__   :							Optional[Any]      ,		lowercase__   :							List[str]      ,		lowercase__   :							Any      ,		lowercase__   :							Dict      ,		lowercase__   :							List[str]      ,		lowercase__   :							List[str]      ,		lowercase__   :							List[str]      ,		):
       a_		    =  self.num_labels
       a_		    =  ElectraForPreTraining(config=lowercase__       )
       model.to(lowercase__       )
       model.eval()
       a_		    =  model(lowercase__      ,		attention_mask=lowercase__      ,		token_type_ids=lowercase__      ,		labels=lowercase__       )
       self.parent.assertEqual(result.logits.shape      ,		(self.batch_size, self.seq_length)       )



     def 				__magic_name__		(  self   :							Optional[int]      ,		lowercase__   :							Dict      ,		lowercase__   :							Tuple      ,		lowercase__   :							Any      ,		lowercase__   :							Any      ,		lowercase__   :							int      ,		lowercase__   :							List[str]      ,		lowercase__   :							Optional[int]      ,		lowercase__   :							int      ,		):
       a_		    =  self.num_labels
       a_		    =  ElectraForSequenceClassification(lowercase__       )
       model.to(lowercase__       )
       model.eval()
       a_		    =  model(lowercase__      ,		attention_mask=lowercase__      ,		token_type_ids=lowercase__      ,		labels=lowercase__       )
       self.parent.assertEqual(result.logits.shape      ,		(self.batch_size, self.num_labels)       )



     def 				__magic_name__		(  self   :							Any      ,		lowercase__   :							Union[str, Any]      ,		lowercase__   :							int      ,		lowercase__   :							Any      ,		lowercase__   :							List[Any]      ,		lowercase__   :							Optional[int]      ,		lowercase__   :							Optional[int]      ,		lowercase__   :							List[str]      ,		lowercase__   :							Optional[Any]      ,		):
       a_		    =  ElectraForQuestionAnswering(config=lowercase__       )
       model.to(lowercase__       )
       model.eval()
       a_		    =  model(
           lowercase__      ,		attention_mask=lowercase__      ,		token_type_ids=lowercase__      ,		start_positions=lowercase__      ,		end_positions=lowercase__      ,		)
       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 				__magic_name__		(  self   :							int      ,		lowercase__   :							List[str]      ,		lowercase__   :							List[Any]      ,		lowercase__   :							Union[str, Any]      ,		lowercase__   :							Tuple      ,		lowercase__   :							List[Any]      ,		lowercase__   :							List[Any]      ,		lowercase__   :							Dict      ,		lowercase__   :							Optional[Any]      ,		):
       a_		    =  self.num_choices
       a_		    =  ElectraForMultipleChoice(config=lowercase__       )
       model.to(lowercase__       )
       model.eval()
       a_		    =  input_ids.unsqueeze(1       ).expand(-1      ,		self.num_choices      ,		-1       ).contiguous()
       a_		    =  token_type_ids.unsqueeze(1       ).expand(-1      ,		self.num_choices      ,		-1       ).contiguous()
       a_		    =  input_mask.unsqueeze(1       ).expand(-1      ,		self.num_choices      ,		-1       ).contiguous()
       a_		    =  model(
           lowercase__      ,		attention_mask=lowercase__      ,		token_type_ids=lowercase__      ,		labels=lowercase__      ,		)
       self.parent.assertEqual(result.logits.shape      ,		(self.batch_size, self.num_choices)       )



     def 				__magic_name__		(  self   :							Tuple       ):
       a_		    =  self.prepare_config_and_inputs()
       (
           (
           a_
       )    , (
           a_
       )    , (
           a_
       )    , (
           a_
       )    , (
           a_
       )    , (
           a_
       )    , (
           a_
       )    , (
           a_
       )    , 
       )		    =  config_and_inputs
       a_		    =  {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
       return config, inputs_dict



@require_torch
class 							__lowercase   (			a__	,		a__	,		unittest.TestCase    ):
     _lowerCAmelCase		       =						(
         (
             ElectraModel,
             ElectraForPreTraining,
             ElectraForMaskedLM,
             ElectraForCausalLM,
             ElectraForMultipleChoice,
             ElectraForTokenClassification,
             ElectraForSequenceClassification,
             ElectraForQuestionAnswering,
         )
         if is_torch_available()
         else ()
     )
     _lowerCAmelCase		       =						(
         {
             "feature-extraction": ElectraModel,
             "fill-mask": ElectraForMaskedLM,
             "question-answering": ElectraForQuestionAnswering,
             "text-classification": ElectraForSequenceClassification,
             "text-generation": ElectraForCausalLM,
             "token-classification": ElectraForTokenClassification,
             "zero-shot": ElectraForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )
     _lowerCAmelCase		       =						True



     def 				__magic_name__		(  self   :							Tuple      ,		lowercase__   :							Optional[int]      ,		lowercase__   :							List[Any]      ,		lowercase__   :							Dict=False       ):
       a_		    =  super()._prepare_for_class(lowercase__      ,		lowercase__      ,		return_labels=lowercase__       )

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



     def 				__magic_name__		(  self   :							List[str]       ):
       a_		    =  ElectraModelTester(self       )
       a_		    =  ConfigTester(self      ,		config_class=lowercase__      ,		hidden_size=3_7       )



     def 				__magic_name__		(  self   :							str       ):
       self.config_tester.run_common_tests()



     def 				__magic_name__		(  self   :							Any       ):
       a_		    =  self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_electra_model(*lowercase__       )



     def 				__magic_name__		(  self   :							Optional[Any]       ):
       a_		    =  self.model_tester.prepare_config_and_inputs_for_decoder()
       self.model_tester.create_and_check_electra_model_as_decoder(*lowercase__       )



     def 				__magic_name__		(  self   :							int       ):
       a_		    =  self.model_tester.prepare_config_and_inputs()
       for type in ["absolute", "relative_key", "relative_key_query"]:
         a_		    =  type
         self.model_tester.create_and_check_electra_model(*lowercase__       )



     def 				__magic_name__		(  self   :							List[str]       ):
       a_		    =  self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_electra_for_masked_lm(*lowercase__       )



     def 				__magic_name__		(  self   :							Optional[int]       ):
       a_		    =  self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_electra_for_token_classification(*lowercase__       )



     def 				__magic_name__		(  self   :							Optional[Any]       ):
       a_		    =  self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_electra_for_pretraining(*lowercase__       )



     def 				__magic_name__		(  self   :							List[Any]       ):
       a_		    =  self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_electra_for_sequence_classification(*lowercase__       )



     def 				__magic_name__		(  self   :							List[str]       ):
       a_		    =  self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_electra_for_question_answering(*lowercase__       )



     def 				__magic_name__		(  self   :							str       ):
       a_		    =  self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_electra_for_multiple_choice(*lowercase__       )



     @slow
     def 				__magic_name__		(  self   :							Union[str, Any]       ):
       for model_name in ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         a_		    =  ElectraModel.from_pretrained(lowercase__       )
         self.assertIsNotNone(lowercase__       )



     def 				__magic_name__		(  self   :							Dict       ):
       a_		    =  self.model_tester.prepare_config_and_inputs_for_decoder()
       self.model_tester.create_and_check_electra_for_causal_lm(*lowercase__       )



@require_torch
class 							__lowercase   (			unittest.TestCase    ):



     @slow
     def 				__magic_name__		(  self   :							Tuple       ):
       a_		    =  ElectraModel.from_pretrained('''google/electra-small-discriminator'''       )
       a_		    =  torch.tensor([[0, 3_4_5, 2_3_2, 3_2_8, 7_4_0, 1_4_0, 1_6_9_5, 6_9, 6_0_7_8, 1_5_8_8, 2]]       )
       a_		    =  torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]       )
       a_		    =  model(lowercase__      ,		attention_mask=lowercase__       )[0]
       a_		    =  torch.Size((1, 1_1, 2_5_6)       )
       self.assertEqual(output.shape      ,		lowercase__       )
       a_		    =  torch.tensor(
           [[[0.4471, 0.6821, -0.3265], [0.4627, 0.5255, -0.3668], [0.4532, 0.3313, -0.4344]]]       )

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