

"""simple docstring"""




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 		_A							:





      def __init__(	self     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__=13     ,    SCREAMING_SNAKE_CASE__=7     ,    SCREAMING_SNAKE_CASE__=True     ,    SCREAMING_SNAKE_CASE__=True     ,    SCREAMING_SNAKE_CASE__=True     ,    SCREAMING_SNAKE_CASE__=True     ,    SCREAMING_SNAKE_CASE__=99     ,    SCREAMING_SNAKE_CASE__=32     ,    SCREAMING_SNAKE_CASE__=5     ,    SCREAMING_SNAKE_CASE__=4     ,    SCREAMING_SNAKE_CASE__=37     ,    SCREAMING_SNAKE_CASE__="gelu"     ,    SCREAMING_SNAKE_CASE__=0.1     ,    SCREAMING_SNAKE_CASE__=0.1     ,    SCREAMING_SNAKE_CASE__=512     ,    SCREAMING_SNAKE_CASE__=16     ,    SCREAMING_SNAKE_CASE__=2     ,    SCREAMING_SNAKE_CASE__=0.02     ,    SCREAMING_SNAKE_CASE__=3     ,    SCREAMING_SNAKE_CASE__=4     ,    SCREAMING_SNAKE_CASE__=None     ,    ) ->       Tuple:
         lowerCamelCase__						       =      parent
         lowerCamelCase__						       =      batch_size
         lowerCamelCase__						       =      seq_length
         lowerCamelCase__						       =      is_training
         lowerCamelCase__						       =      use_input_mask
         lowerCamelCase__						       =      use_token_type_ids
         lowerCamelCase__						       =      use_labels
         lowerCamelCase__						       =      vocab_size
         lowerCamelCase__						       =      hidden_size
         lowerCamelCase__						       =      num_hidden_layers
         lowerCamelCase__						       =      num_attention_heads
         lowerCamelCase__						       =      intermediate_size
         lowerCamelCase__						       =      hidden_act
         lowerCamelCase__						       =      hidden_dropout_prob
         lowerCamelCase__						       =      attention_probs_dropout_prob
         lowerCamelCase__						       =      max_position_embeddings
         lowerCamelCase__						       =      type_vocab_size
         lowerCamelCase__						       =      type_sequence_label_size
         lowerCamelCase__						       =      initializer_range
         lowerCamelCase__						       =      num_labels
         lowerCamelCase__						       =      num_choices
         lowerCamelCase__						       =      scope





      def        _lowerCamelCase	(	self		) ->       List[Any]:
         lowerCamelCase__						       =      ids_tensor([self.batch_size, self.seq_length]     ,    self.vocab_size		)

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

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

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

         lowerCamelCase__						       =      self.get_config()

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





      def        _lowerCamelCase	(	self		) ->       Tuple:
         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=SCREAMING_SNAKE_CASE__     ,    initializer_range=self.initializer_range     ,    )





      def        _lowerCamelCase	(	self		) ->       Optional[int]:
         (
             (
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							
         )						       =      self.prepare_config_and_inputs()

         lowerCamelCase__						       =      True
         lowerCamelCase__						       =      floats_tensor([self.batch_size, self.seq_length, self.hidden_size]		)
         lowerCamelCase__						       =      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        _lowerCamelCase	(	self     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    ) ->       str:
         lowerCamelCase__						       =      ElectraModel(config=SCREAMING_SNAKE_CASE__		)
         model.to(SCREAMING_SNAKE_CASE__		)
         model.eval()
         lowerCamelCase__						       =      model(SCREAMING_SNAKE_CASE__     ,    attention_mask=SCREAMING_SNAKE_CASE__     ,    token_type_ids=SCREAMING_SNAKE_CASE__		)
         lowerCamelCase__						       =      model(SCREAMING_SNAKE_CASE__     ,    token_type_ids=SCREAMING_SNAKE_CASE__		)
         lowerCamelCase__						       =      model(SCREAMING_SNAKE_CASE__		)
         self.parent.assertEqual(result.last_hidden_state.shape     ,    (self.batch_size, self.seq_length, self.hidden_size)		)





      def        _lowerCamelCase	(	self     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    ) ->       Any:
         lowerCamelCase__						       =      True
         lowerCamelCase__						       =      ElectraModel(SCREAMING_SNAKE_CASE__		)
         model.to(SCREAMING_SNAKE_CASE__		)
         model.eval()
         lowerCamelCase__						       =      model(
             SCREAMING_SNAKE_CASE__     ,    attention_mask=SCREAMING_SNAKE_CASE__     ,    token_type_ids=SCREAMING_SNAKE_CASE__     ,    encoder_hidden_states=SCREAMING_SNAKE_CASE__     ,    encoder_attention_mask=SCREAMING_SNAKE_CASE__     ,    )
         lowerCamelCase__						       =      model(
             SCREAMING_SNAKE_CASE__     ,    attention_mask=SCREAMING_SNAKE_CASE__     ,    token_type_ids=SCREAMING_SNAKE_CASE__     ,    encoder_hidden_states=SCREAMING_SNAKE_CASE__     ,    )
         lowerCamelCase__						       =      model(SCREAMING_SNAKE_CASE__     ,    attention_mask=SCREAMING_SNAKE_CASE__     ,    token_type_ids=SCREAMING_SNAKE_CASE__		)
         self.parent.assertEqual(result.last_hidden_state.shape     ,    (self.batch_size, self.seq_length, self.hidden_size)		)





      def        _lowerCamelCase	(	self     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    ) ->       Dict:
         lowerCamelCase__						       =      ElectraForMaskedLM(config=SCREAMING_SNAKE_CASE__		)
         model.to(SCREAMING_SNAKE_CASE__		)
         model.eval()
         lowerCamelCase__						       =      model(SCREAMING_SNAKE_CASE__     ,    attention_mask=SCREAMING_SNAKE_CASE__     ,    token_type_ids=SCREAMING_SNAKE_CASE__     ,    labels=SCREAMING_SNAKE_CASE__		)
         self.parent.assertEqual(result.logits.shape     ,    (self.batch_size, self.seq_length, self.vocab_size)		)





      def        _lowerCamelCase	(	self     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    ) ->       str:
         lowerCamelCase__						       =      ElectraForCausalLM(config=SCREAMING_SNAKE_CASE__		)
         model.to(SCREAMING_SNAKE_CASE__		)
         model.eval()
         lowerCamelCase__						       =      model(SCREAMING_SNAKE_CASE__     ,    attention_mask=SCREAMING_SNAKE_CASE__     ,    token_type_ids=SCREAMING_SNAKE_CASE__     ,    labels=SCREAMING_SNAKE_CASE__		)
         self.parent.assertEqual(result.logits.shape     ,    (self.batch_size, self.seq_length, self.vocab_size)		)





      def        _lowerCamelCase	(	self     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    ) ->       str:
         lowerCamelCase__						       =      self.num_labels
         lowerCamelCase__						       =      ElectraForTokenClassification(config=SCREAMING_SNAKE_CASE__		)
         model.to(SCREAMING_SNAKE_CASE__		)
         model.eval()
         lowerCamelCase__						       =      model(SCREAMING_SNAKE_CASE__     ,    attention_mask=SCREAMING_SNAKE_CASE__     ,    token_type_ids=SCREAMING_SNAKE_CASE__     ,    labels=SCREAMING_SNAKE_CASE__		)
         self.parent.assertEqual(result.logits.shape     ,    (self.batch_size, self.seq_length, self.num_labels)		)





      def        _lowerCamelCase	(	self     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    ) ->       Dict:
         lowerCamelCase__						       =      self.num_labels
         lowerCamelCase__						       =      ElectraForPreTraining(config=SCREAMING_SNAKE_CASE__		)
         model.to(SCREAMING_SNAKE_CASE__		)
         model.eval()
         lowerCamelCase__						       =      model(SCREAMING_SNAKE_CASE__     ,    attention_mask=SCREAMING_SNAKE_CASE__     ,    token_type_ids=SCREAMING_SNAKE_CASE__     ,    labels=SCREAMING_SNAKE_CASE__		)
         self.parent.assertEqual(result.logits.shape     ,    (self.batch_size, self.seq_length)		)





      def        _lowerCamelCase	(	self     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    ) ->       Optional[Any]:
         lowerCamelCase__						       =      self.num_labels
         lowerCamelCase__						       =      ElectraForSequenceClassification(SCREAMING_SNAKE_CASE__		)
         model.to(SCREAMING_SNAKE_CASE__		)
         model.eval()
         lowerCamelCase__						       =      model(SCREAMING_SNAKE_CASE__     ,    attention_mask=SCREAMING_SNAKE_CASE__     ,    token_type_ids=SCREAMING_SNAKE_CASE__     ,    labels=SCREAMING_SNAKE_CASE__		)
         self.parent.assertEqual(result.logits.shape     ,    (self.batch_size, self.num_labels)		)





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





      def        _lowerCamelCase	(	self		) ->       Union[str, Any]:
         lowerCamelCase__						       =      self.prepare_config_and_inputs()
         (
             (
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							(
             lowerCamelCase__
         )       ,							
         )						       =      config_and_inputs
         lowerCamelCase__						       =      {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
         return config, inputs_dict






@require_torch
class 		_A							(      __a					,							__a					,							unittest.TestCase       ):
      __a             =						(
          (
              ElectraModel,
              ElectraForPreTraining,
              ElectraForMaskedLM,
              ElectraForCausalLM,
              ElectraForMultipleChoice,
              ElectraForTokenClassification,
              ElectraForSequenceClassification,
              ElectraForQuestionAnswering,
          )
          if is_torch_available()
          else ()
      )
      __a             =						(
          {
              '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 {}
      )
      __a             =						True





      def        _lowerCamelCase	(	self     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__     ,    SCREAMING_SNAKE_CASE__=False		) ->       List[Any]:
         lowerCamelCase__						       =      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__						       =      torch.zeros(
                   (self.model_tester.batch_size, self.model_tester.seq_length)     ,    dtype=torch.long     ,    device=SCREAMING_SNAKE_CASE__		)
         return inputs_dict





      def        _lowerCamelCase	(	self		) ->       Tuple:
         lowerCamelCase__						       =      ElectraModelTester(self		)
         lowerCamelCase__						       =      ConfigTester(self     ,    config_class=SCREAMING_SNAKE_CASE__     ,    hidden_size=37		)





      def        _lowerCamelCase	(	self		) ->       str:
         self.config_tester.run_common_tests()





      def        _lowerCamelCase	(	self		) ->       Optional[Any]:
         lowerCamelCase__						       =      self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_model(*SCREAMING_SNAKE_CASE__		)





      def        _lowerCamelCase	(	self		) ->       int:
         lowerCamelCase__						       =      self.model_tester.prepare_config_and_inputs_for_decoder()
         self.model_tester.create_and_check_electra_model_as_decoder(*SCREAMING_SNAKE_CASE__		)





      def        _lowerCamelCase	(	self		) ->       List[Any]:
         lowerCamelCase__						       =      self.model_tester.prepare_config_and_inputs()
         for type in ["absolute", "relative_key", "relative_key_query"]:
            lowerCamelCase__						       =      type
            self.model_tester.create_and_check_electra_model(*SCREAMING_SNAKE_CASE__		)





      def        _lowerCamelCase	(	self		) ->       str:
         lowerCamelCase__						       =      self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_for_masked_lm(*SCREAMING_SNAKE_CASE__		)





      def        _lowerCamelCase	(	self		) ->       List[str]:
         lowerCamelCase__						       =      self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_for_token_classification(*SCREAMING_SNAKE_CASE__		)





      def        _lowerCamelCase	(	self		) ->       int:
         lowerCamelCase__						       =      self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_for_pretraining(*SCREAMING_SNAKE_CASE__		)





      def        _lowerCamelCase	(	self		) ->       List[Any]:
         lowerCamelCase__						       =      self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_for_sequence_classification(*SCREAMING_SNAKE_CASE__		)





      def        _lowerCamelCase	(	self		) ->       Dict:
         lowerCamelCase__						       =      self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_for_question_answering(*SCREAMING_SNAKE_CASE__		)





      def        _lowerCamelCase	(	self		) ->       Union[str, Any]:
         lowerCamelCase__						       =      self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_electra_for_multiple_choice(*SCREAMING_SNAKE_CASE__		)





      @slow
      def        _lowerCamelCase	(	self		) ->       List[str]:
         for model_name in ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
            lowerCamelCase__						       =      ElectraModel.from_pretrained(SCREAMING_SNAKE_CASE__		)
            self.assertIsNotNone(SCREAMING_SNAKE_CASE__		)





      def        _lowerCamelCase	(	self		) ->       Union[str, Any]:
         lowerCamelCase__						       =      self.model_tester.prepare_config_and_inputs_for_decoder()
         self.model_tester.create_and_check_electra_for_causal_lm(*SCREAMING_SNAKE_CASE__		)






@require_torch
class 		_A							(      unittest.TestCase       ):





      @slow
      def        _lowerCamelCase	(	self		) ->       Optional[Any]:
         lowerCamelCase__						       =      ElectraModel.from_pretrained("google/electra-small-discriminator"		)
         lowerCamelCase__						       =      torch.tensor([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]		)
         lowerCamelCase__						       =      torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]		)
         lowerCamelCase__						       =      model(SCREAMING_SNAKE_CASE__     ,    attention_mask=SCREAMING_SNAKE_CASE__		)[0]
         lowerCamelCase__						       =      torch.Size((1, 11, 256)		)
         self.assertEqual(output.shape     ,    SCREAMING_SNAKE_CASE__		)
         lowerCamelCase__						       =      torch.tensor(
             [[[0.44_71, 0.68_21, -0.32_65], [0.46_27, 0.52_55, -0.36_68], [0.45_32, 0.33_13, -0.43_44]]]		)

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







"""simple docstring"""




SCREAMING_SNAKE_CASE_  :      Optional[int]							=      {0: [1, 2], 1: [0, 3], 2: [0], 3: [1], 4: [5, 6], 5: [4, 6], 6: [4, 5]}

SCREAMING_SNAKE_CASE_  :      str							=      {0: [1, 2, 3], 1: [0, 3], 2: [0], 3: [0, 1], 4: [], 5: []}



def 						UpperCAmelCase__ (					A__						,     A__						,     A__ )   ->   list:




   """simple docstring"""
   lowerCamelCase__						       =      True
   lowerCamelCase__						       =      []

   for neighbour in graph[vert]:
      if not visited[neighbour]:
         connected_verts += dfs(A__						,     A__						,     A__ )

   return [vert, *connected_verts]



def 						UpperCAmelCase__ (					A__ )   ->   list:




   """simple docstring"""
   lowerCamelCase__						       =      len(A__ )
   lowerCamelCase__						       =      graph_size * [False]
   lowerCamelCase__						       =      []

   for i in range(A__ ):
      if not visited[i]:
         lowerCamelCase__						       =      dfs(A__						,     A__						,     A__ )
         components_list.append(A__ )

   return components_list


if __name__ == "__main__":
     import doctest

     doctest.testmod()




