


"""simple docstring"""


import os
import tempfile
import unittest

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

from ...generation.test_utils import GenerationTesterMixin
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,
        NezhaForMaskedLM,
        NezhaForMultipleChoice,
        NezhaForNextSentencePrediction,
        NezhaForPreTraining,
        NezhaForQuestionAnswering,
        NezhaForSequenceClassification,
        NezhaForTokenClassification,
        NezhaModel,
    )
    from transformers.models.nezha.modeling_nezha import NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST


class 			A__	:


     """simple docstring"""

     def __init__(	self:						Optional[Any]     ,		__a:						Tuple     ,		__a:						Optional[Any]=13     ,		__a:						List[str]=7     ,		__a:						Union[str, Any]=True     ,		__a:						List[Any]=True     ,		__a:						Any=True     ,		__a:						List[str]=True     ,		__a:						Any=99     ,		__a:						Tuple=32     ,		__a:						List[Any]=5     ,		__a:						Dict=4     ,		__a:						Union[str, Any]=37     ,		__a:						Dict="gelu"     ,		__a:						Union[str, Any]=0.1     ,		__a:						Tuple=0.1     ,		__a:						str=128     ,		__a:						int=32     ,		__a:						Union[str, Any]=16     ,		__a:						Dict=2     ,		__a:						Union[str, Any]=0.02     ,		__a:						str=3     ,		__a:						Optional[Any]=4     ,		__a:						List[Any]=None     ,		)->    Any:
           lowerCamelCase					:					List[Any]        =	parent
           lowerCamelCase					:					Dict        =	batch_size
           lowerCamelCase					:					List[Any]        =	seq_length
           lowerCamelCase					:					Any        =	is_training
           lowerCamelCase					:					int        =	use_input_mask
           lowerCamelCase					:					int        =	use_token_type_ids
           lowerCamelCase					:					Optional[int]        =	use_labels
           lowerCamelCase					:					int        =	vocab_size
           lowerCamelCase					:					List[Any]        =	hidden_size
           lowerCamelCase					:					int        =	num_hidden_layers
           lowerCamelCase					:					List[Any]        =	num_attention_heads
           lowerCamelCase					:					str        =	intermediate_size
           lowerCamelCase					:					Any        =	hidden_act
           lowerCamelCase					:					str        =	hidden_dropout_prob
           lowerCamelCase					:					Any        =	attention_probs_dropout_prob
           lowerCamelCase					:					List[Any]        =	max_position_embeddings
           lowerCamelCase					:					Optional[int]        =	type_vocab_size
           lowerCamelCase					:					Optional[Any]        =	type_sequence_label_size
           lowerCamelCase					:					Optional[Any]        =	initializer_range
           lowerCamelCase					:					Dict        =	num_labels
           lowerCamelCase					:					Optional[Any]        =	num_choices
           lowerCamelCase					:					Dict        =	scope

     def 		a__						(	self:						Tuple	)->    Union[str, Any]:
           lowerCamelCase					:					Optional[int]        =	ids_tensor([self.batch_size, self.seq_length]     ,		self.vocab_size	)

           lowerCamelCase					:					str        =	None
           if self.use_input_mask:
                 lowerCamelCase					:					Tuple        =	random_attention_mask([self.batch_size, self.seq_length]	)

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

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

           lowerCamelCase					:					List[Any]        =	self.get_config()

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

     def 		a__						(	self:						Union[str, Any]	)->    int:
           return NezhaConfig(
               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=__a     ,		initializer_range=self.initializer_range     ,		)

     def 		a__						(	self:						List[str]	)->    List[Any]:
           (
               (
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			
           )					:					List[Any]        =	self.prepare_config_and_inputs()

           lowerCamelCase					:					Tuple        =	True
           lowerCamelCase					:					List[Any]        =	floats_tensor([self.batch_size, self.seq_length, self.hidden_size]	)
           lowerCamelCase					:					Optional[int]        =	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 		a__						(	self:						Dict     ,		__a:						List[Any]     ,		__a:						Union[str, Any]     ,		__a:						Union[str, Any]     ,		__a:						List[str]     ,		__a:						List[str]     ,		__a:						int     ,		__a:						List[Any]	)->    Union[str, Any]:
           lowerCamelCase					:					Tuple        =	NezhaModel(config=__a	)
           model.to(__a	)
           model.eval()
           lowerCamelCase					:					List[Any]        =	model(__a     ,		attention_mask=__a     ,		token_type_ids=__a	)
           lowerCamelCase					:					str        =	model(__a     ,		token_type_ids=__a	)
           lowerCamelCase					:					Any        =	model(__a	)
           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 		a__						(	self:						Any     ,		__a:						Dict     ,		__a:						Tuple     ,		__a:						str     ,		__a:						List[str]     ,		__a:						List[str]     ,		__a:						Optional[Any]     ,		__a:						List[Any]     ,		__a:						Tuple     ,		__a:						Tuple     ,		)->    Dict:
           lowerCamelCase					:					Optional[Any]        =	True
           lowerCamelCase					:					Union[str, Any]        =	NezhaModel(__a	)
           model.to(__a	)
           model.eval()
           lowerCamelCase					:					int        =	model(
               __a     ,		attention_mask=__a     ,		token_type_ids=__a     ,		encoder_hidden_states=__a     ,		encoder_attention_mask=__a     ,		)
           lowerCamelCase					:					List[str]        =	model(
               __a     ,		attention_mask=__a     ,		token_type_ids=__a     ,		encoder_hidden_states=__a     ,		)
           lowerCamelCase					:					List[str]        =	model(__a     ,		attention_mask=__a     ,		token_type_ids=__a	)
           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 		a__						(	self:						Tuple     ,		__a:						Optional[int]     ,		__a:						List[str]     ,		__a:						Union[str, Any]     ,		__a:						Union[str, Any]     ,		__a:						str     ,		__a:						Optional[Any]     ,		__a:						Optional[int]	)->    Tuple:
           lowerCamelCase					:					Union[str, Any]        =	NezhaForMaskedLM(config=__a	)
           model.to(__a	)
           model.eval()
           lowerCamelCase					:					Optional[Any]        =	model(__a     ,		attention_mask=__a     ,		token_type_ids=__a     ,		labels=__a	)
           self.parent.assertEqual(result.logits.shape     ,		(self.batch_size, self.seq_length, self.vocab_size)	)

     def 		a__						(	self:						str     ,		__a:						List[Any]     ,		__a:						Optional[int]     ,		__a:						List[Any]     ,		__a:						str     ,		__a:						Optional[Any]     ,		__a:						List[Any]     ,		__a:						Dict	)->    Any:
           lowerCamelCase					:					Optional[int]        =	NezhaForNextSentencePrediction(config=__a	)
           model.to(__a	)
           model.eval()
           lowerCamelCase					:					List[Any]        =	model(
               __a     ,		attention_mask=__a     ,		token_type_ids=__a     ,		labels=__a     ,		)
           self.parent.assertEqual(result.logits.shape     ,		(self.batch_size, 2)	)

     def 		a__						(	self:						Dict     ,		__a:						List[Any]     ,		__a:						int     ,		__a:						List[Any]     ,		__a:						Union[str, Any]     ,		__a:						Optional[int]     ,		__a:						List[Any]     ,		__a:						Optional[int]	)->    List[Any]:
           lowerCamelCase					:					List[Any]        =	NezhaForPreTraining(config=__a	)
           model.to(__a	)
           model.eval()
           lowerCamelCase					:					Any        =	model(
               __a     ,		attention_mask=__a     ,		token_type_ids=__a     ,		labels=__a     ,		next_sentence_label=__a     ,		)
           self.parent.assertEqual(result.prediction_logits.shape     ,		(self.batch_size, self.seq_length, self.vocab_size)	)
           self.parent.assertEqual(result.seq_relationship_logits.shape     ,		(self.batch_size, 2)	)

     def 		a__						(	self:						List[Any]     ,		__a:						str     ,		__a:						Any     ,		__a:						Optional[int]     ,		__a:						Union[str, Any]     ,		__a:						Tuple     ,		__a:						Dict     ,		__a:						List[str]	)->    Dict:
           lowerCamelCase					:					str        =	NezhaForQuestionAnswering(config=__a	)
           model.to(__a	)
           model.eval()
           lowerCamelCase					:					int        =	model(
               __a     ,		attention_mask=__a     ,		token_type_ids=__a     ,		start_positions=__a     ,		end_positions=__a     ,		)
           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 		a__						(	self:						Any     ,		__a:						List[Any]     ,		__a:						Optional[int]     ,		__a:						Tuple     ,		__a:						List[Any]     ,		__a:						str     ,		__a:						int     ,		__a:						Optional[int]	)->    str:
           lowerCamelCase					:					int        =	self.num_labels
           lowerCamelCase					:					List[Any]        =	NezhaForSequenceClassification(__a	)
           model.to(__a	)
           model.eval()
           lowerCamelCase					:					str        =	model(__a     ,		attention_mask=__a     ,		token_type_ids=__a     ,		labels=__a	)
           self.parent.assertEqual(result.logits.shape     ,		(self.batch_size, self.num_labels)	)

     def 		a__						(	self:						Tuple     ,		__a:						Dict     ,		__a:						Dict     ,		__a:						Any     ,		__a:						str     ,		__a:						List[str]     ,		__a:						Optional[Any]     ,		__a:						Dict	)->    Tuple:
           lowerCamelCase					:					List[str]        =	self.num_labels
           lowerCamelCase					:					int        =	NezhaForTokenClassification(config=__a	)
           model.to(__a	)
           model.eval()
           lowerCamelCase					:					Optional[int]        =	model(__a     ,		attention_mask=__a     ,		token_type_ids=__a     ,		labels=__a	)
           self.parent.assertEqual(result.logits.shape     ,		(self.batch_size, self.seq_length, self.num_labels)	)

     def 		a__						(	self:						Any     ,		__a:						List[Any]     ,		__a:						int     ,		__a:						Union[str, Any]     ,		__a:						Optional[Any]     ,		__a:						Tuple     ,		__a:						List[Any]     ,		__a:						Dict	)->    int:
           lowerCamelCase					:					Any        =	self.num_choices
           lowerCamelCase					:					Union[str, Any]        =	NezhaForMultipleChoice(config=__a	)
           model.to(__a	)
           model.eval()
           lowerCamelCase					:					Any        =	input_ids.unsqueeze(1	).expand(-1     ,		self.num_choices     ,		-1	).contiguous()
           lowerCamelCase					:					Tuple        =	token_type_ids.unsqueeze(1	).expand(-1     ,		self.num_choices     ,		-1	).contiguous()
           lowerCamelCase					:					Optional[Any]        =	input_mask.unsqueeze(1	).expand(-1     ,		self.num_choices     ,		-1	).contiguous()
           lowerCamelCase					:					Tuple        =	model(
               __a     ,		attention_mask=__a     ,		token_type_ids=__a     ,		labels=__a     ,		)
           self.parent.assertEqual(result.logits.shape     ,		(self.batch_size, self.num_choices)	)







     def 		a__						(	self:						Optional[Any]	)->    List[Any]:
           lowerCamelCase					:					Optional[Any]        =	self.prepare_config_and_inputs()
           (
               (
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			
           )					:					Optional[Any]        =	config_and_inputs
           lowerCamelCase					:					Optional[Any]        =	{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
           return config, inputs_dict


@require_torch
class 			A__	(						__lowercase ,     __lowercase ,     __lowercase ,     unittest.TestCase):


     """simple docstring"""
     snake_case__	:					Any													=(
         (
             NezhaModel,
             NezhaForMaskedLM,
             NezhaForMultipleChoice,
             NezhaForNextSentencePrediction,
             NezhaForPreTraining,
             NezhaForQuestionAnswering,
             NezhaForSequenceClassification,
             NezhaForTokenClassification,
         )
         if is_torch_available()
         else ()
     )
     snake_case__	:					Dict													=(
         {
             '''feature-extraction''': NezhaModel,
             '''fill-mask''': NezhaForMaskedLM,
             '''question-answering''': NezhaForQuestionAnswering,
             '''text-classification''': NezhaForSequenceClassification,
             '''token-classification''': NezhaForTokenClassification,
             '''zero-shot''': NezhaForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )
     snake_case__	:					Union[str, Any]													=True

     def 		a__						(	self:						str     ,		__a:						Any     ,		__a:						str     ,		__a:						int=False	)->    Optional[int]:
           lowerCamelCase					:					Dict        =	super()._prepare_for_class(__a     ,		__a     ,		return_labels=__a	)

           if return_labels:
                 if model_class in get_values(__a	):
                       lowerCamelCase					:					int        =	torch.zeros(
                           (self.model_tester.batch_size, self.model_tester.seq_length)     ,		dtype=torch.long     ,		device=__a	)
                       lowerCamelCase					:					str        =	torch.zeros(
                           self.model_tester.batch_size     ,		dtype=torch.long     ,		device=__a	)
           return inputs_dict

     def 		a__						(	self:						Tuple	)->    Dict:
           lowerCamelCase					:					Union[str, Any]        =	NezhaModelTester(self	)
           lowerCamelCase					:					Optional[Any]        =	ConfigTester(self     ,		config_class=__a     ,		hidden_size=37	)

     def 		a__						(	self:						str	)->    List[str]:
           self.config_tester.run_common_tests()

     def 		a__						(	self:						Union[str, Any]	)->    str:
           lowerCamelCase					:					str        =	self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_model(*__a	)

     def 		a__						(	self:						Optional[int]	)->    str:
           lowerCamelCase					:					Dict        =	self.model_tester.prepare_config_and_inputs_for_decoder()
           self.model_tester.create_and_check_model_as_decoder(*__a	)

     def 		a__						(	self:						Union[str, Any]	)->    Dict:
           # This regression test was failing with PyTorch < 1.3
           (
               (
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			(
               lowerCamelCase
           )     ,			
           )					:					Tuple        =	self.model_tester.prepare_config_and_inputs_for_decoder()

           lowerCamelCase					:					Dict        =	None

           self.model_tester.create_and_check_model_as_decoder(
               __a     ,		__a     ,		__a     ,		__a     ,		__a     ,		__a     ,		__a     ,		__a     ,		__a     ,		)

     def 		a__						(	self:						int	)->    Tuple:
           lowerCamelCase					:					Optional[Any]        =	self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_masked_lm(*__a	)

     def 		a__						(	self:						Optional[Any]	)->    int:
           lowerCamelCase					:					Optional[Any]        =	self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_multiple_choice(*__a	)

     def 		a__						(	self:						Optional[int]	)->    Optional[int]:
           lowerCamelCase					:					Dict        =	self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_next_sequence_prediction(*__a	)

     def 		a__						(	self:						str	)->    str:
           lowerCamelCase					:					Tuple        =	self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_pretraining(*__a	)

     def 		a__						(	self:						int	)->    Optional[Any]:
           lowerCamelCase					:					Tuple        =	self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_question_answering(*__a	)

     def 		a__						(	self:						Dict	)->    str:
           lowerCamelCase					:					Optional[Any]        =	self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_sequence_classification(*__a	)

     def 		a__						(	self:						List[Any]	)->    str:
           lowerCamelCase					:					Any        =	self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_token_classification(*__a	)

     @slow
     def 		a__						(	self:						Tuple	)->    Optional[int]:
           for model_name in NEZHA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                 lowerCamelCase					:					Optional[int]        =	NezhaModel.from_pretrained(__a	)
                 self.assertIsNotNone(__a	)







     @slow
     @require_torch_gpu
     def 		a__						(	self:						List[Any]	)->    Tuple:
           lowerCamelCase     ,			lowerCamelCase					:					Optional[int]        =	self.model_tester.prepare_config_and_inputs_for_common()
           for model_class in self.all_model_classes:
                 # NezhaForMultipleChoice behaves incorrectly in JIT environments.
                 if model_class == NezhaForMultipleChoice:
                       return

                 lowerCamelCase					:					int        =	True
                 lowerCamelCase					:					Dict        =	model_class(config=__a	)

                 lowerCamelCase					:					int        =	self._prepare_for_class(__a     ,		__a	)
                 lowerCamelCase					:					Optional[Any]        =	torch.jit.trace(
                     __a     ,		(inputs_dict["""input_ids"""].to("""cpu"""	), inputs_dict["""attention_mask"""].to("""cpu"""	))	)

                 with tempfile.TemporaryDirectory() as tmp:
                       torch.jit.save(__a     ,		os.path.join(__a     ,		"""bert.pt"""	)	)
                       lowerCamelCase					:					Union[str, Any]        =	torch.jit.load(os.path.join(__a     ,		"""bert.pt"""	)     ,		map_location=__a	)
                       loaded(inputs_dict["""input_ids"""].to(__a	)     ,		inputs_dict["""attention_mask"""].to(__a	)	)


@require_torch
class 			A__	(						unittest.TestCase):


     """simple docstring"""

     @slow
     def 		a__						(	self:						Optional[Any]	)->    Union[str, Any]:
           lowerCamelCase					:					List[str]        =	NezhaModel.from_pretrained("""sijunhe/nezha-cn-base"""	)
           lowerCamelCase					:					Tuple        =	torch.tensor([[0, 1, 2, 3, 4, 5]]	)
           lowerCamelCase					:					Any        =	torch.tensor([[0, 1, 1, 1, 1, 1]]	)
           with torch.no_grad():
                 lowerCamelCase					:					Optional[int]        =	model(__a     ,		attention_mask=__a	)[0]
           lowerCamelCase					:					Union[str, Any]        =	torch.Size((1, 6, 768)	)
           self.assertEqual(output.shape     ,		__a	)
           lowerCamelCase					:					Any        =	torch.tensor([[[0.06_85, 0.24_41, 0.11_02], [0.06_00, 0.19_06, 0.13_49], [0.02_21, 0.08_19, 0.05_86]]]	)

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







     @slow
     def 		a__						(	self:						List[str]	)->    Optional[int]:
           lowerCamelCase					:					Tuple        =	NezhaForMaskedLM.from_pretrained("""sijunhe/nezha-cn-base"""	)
           lowerCamelCase					:					Union[str, Any]        =	torch.tensor([[0, 1, 2, 3, 4, 5]]	)
           lowerCamelCase					:					List[Any]        =	torch.tensor([[1, 1, 1, 1, 1, 1]]	)
           with torch.no_grad():
                 lowerCamelCase					:					Tuple        =	model(__a     ,		attention_mask=__a	)[0]
           lowerCamelCase					:					Dict        =	torch.Size((1, 6, 21_128)	)
           self.assertEqual(output.shape     ,		__a	)
           lowerCamelCase					:					str        =	torch.tensor(
               [[-2.79_39, -1.79_02, -2.21_89], [-2.85_85, -1.89_08, -2.37_23], [-2.64_99, -1.77_50, -2.25_58]]	)

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








"""simple docstring"""


__lowerCamelCase      :List[Any]	    =		{0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

__lowerCamelCase      :Union[str, Any]	    =		{0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}




def   snake_case		(     UpperCamelCase__       :						dict[int, list[int]]			,				UpperCamelCase__       :						int			,				UpperCamelCase__       :						list[bool]    )   ->      list[int]:
      lowerCamelCase					:					Tuple        =	True
      lowerCamelCase					:					Any        =	[]

      for neighbour in graph[vert]:
            if not visited[neighbour]:
                  order += topology_sort(UpperCamelCase__			,				UpperCamelCase__			,				UpperCamelCase__    )

      order.append(UpperCamelCase__    )

      return order




def   snake_case		(     UpperCamelCase__       :						dict[int, list[int]]			,				UpperCamelCase__       :						int			,				UpperCamelCase__       :						list[bool]    )   ->      list[int]:
      lowerCamelCase					:					List[Any]        =	True
      lowerCamelCase					:					int        =	[vert]

      for neighbour in reversed_graph[vert]:
            if not visited[neighbour]:
                  component += find_components(UpperCamelCase__			,				UpperCamelCase__			,				UpperCamelCase__    )

      return component






def   snake_case		(     UpperCamelCase__       :						dict[int, list[int]]    )   ->      list[list[int]]:
      lowerCamelCase					:					int        =	len(UpperCamelCase__    ) * [False]
      lowerCamelCase					:					dict[int, list[int]]        =	{vert: [] for vert in range(len(UpperCamelCase__    )    )}

      for vert, neighbours in graph.items():
            for neighbour in neighbours:
                  reversed_graph[neighbour].append(UpperCamelCase__    )

      lowerCamelCase					:					int        =	[]
      for i, was_visited in enumerate(UpperCamelCase__    ):
            if not was_visited:
                  order += topology_sort(UpperCamelCase__			,				UpperCamelCase__			,				UpperCamelCase__    )

      lowerCamelCase					:					Tuple        =	[]
      lowerCamelCase					:					str        =	len(UpperCamelCase__    ) * [False]

      for i in range(len(UpperCamelCase__    )    ):
            lowerCamelCase					:					Any        =	order[len(UpperCamelCase__    ) - i - 1]
            if not visited[vert]:
                  lowerCamelCase					:					List[str]        =	find_components(UpperCamelCase__			,				UpperCamelCase__			,				UpperCamelCase__    )
                  components_list.append(UpperCamelCase__    )

      return components_list




