




import math
import sys
class 							__lowercase   :



     def __init__(  self   :							str       ):
       a_		    =  0
       a_		    =  []
       a_		    =  {}  # To store the pos of node in array



     def 				__magic_name__		(  self   :							List[str]       ):
       return self.cur_size == 0



     def 				__magic_name__		(  self   :							Optional[Any]      ,		lowercase__   :							Tuple       ):
       a_		    =  self.left(lowercase__       )
       a_		    =  self.right(lowercase__       )
       if lc < self.cur_size and self.array(lowercase__       )[0] < self.array(lowercase__       )[0]:
         a_		    =  lc
       else:
         a_		    =  idx
       if rc < self.cur_size and self.array(lowercase__       )[0] < self.array(lowercase__       )[0]:
         a_		    =  rc
       if smallest != idx:
         self.swap(lowercase__      ,		lowercase__       )
         self.min_heapify(lowercase__       )



     def 				__magic_name__		(  self   :							Dict      ,		lowercase__   :							List[str]       ):
       # Inserts a node into the Priority Queue
       a_		    =  self.cur_size
       self.cur_size += 1
       self.array.append((sys.maxsize, tup[1])       )
       self.decrease_key((sys.maxsize, tup[1])      ,		tup[0]       )



     def 				__magic_name__		(  self   :							Dict       ):
       # Removes and returns the min element at top of priority queue
       a_		    =  self.array[0][1]
       a_		    =  self.array[self.cur_size - 1]
       self.cur_size -= 1
       self.min_heapify(1       )
       del self.pos[min_node]
       return min_node



     def 				__magic_name__		(  self   :							List[Any]      ,		lowercase__   :							Optional[Any]       ):
       # returns the index of left child
       return 2 * i + 1



     def 				__magic_name__		(  self   :							int      ,		lowercase__   :							Tuple       ):
       # returns the index of right child
       return 2 * i + 2



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



     def 				__magic_name__		(  self   :							Dict      ,		lowercase__   :							Dict      ,		lowercase__   :							Dict       ):
       # swaps array elements at indices i and j
       # update the pos{}
       a_		    =  j
       a_		    =  i
       a_		    =  self.array[i]
       a_		    =  self.array[j]
       a_		    =  temp



     def 				__magic_name__		(  self   :							str      ,		lowercase__   :							Tuple      ,		lowercase__   :							Optional[int]       ):
       a_		    =  self.pos[tup[1]]
       # assuming the new_d is atmost old_d
       a_		    =  (new_d, tup[1])
       while idx > 0 and self.array[self.par(lowercase__       )][0] > self.array[idx][0]:
         self.swap(lowercase__      ,		self.par(lowercase__       )       )
         a_		    =  self.par(lowercase__       )



class 							__lowercase   :



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



     def 				__magic_name__		(  self   :							Tuple      ,		lowercase__   :							int      ,		lowercase__   :							Any      ,		lowercase__   :							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:
         a_		    =  [(v, w)]

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



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



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

       while not q.is_empty():
         a_		    =  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]:
           a_		    =  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__       )
             a_		    =  new_dist
             a_		    =  u

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



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



     def 				__magic_name__		(  self   :							Dict      ,		lowercase__   :							List[str]      ,		lowercase__   :							List[Any]       ):
       # To show the shortest path from src to dest
       # WARNING: Use it *after* calling dijkstra
       a_		    =  []
       a_		    =  0
       a_		    =  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
         a_		    =  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__":
  UpperCamelCase__       				=	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       )       )
