



"""simple docstring"""





import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging


__lowerCAmelCase       :					Tuple      					=					logging.get_logger(__name__)



class    _lowerCAmelCase    (				SCREAMING_SNAKE_CASE__		):





		"""simple docstring"""






		_lowerCamelCase			  =       '''encoder-decoder'''
		_lowerCamelCase			  =       True





		def __init__(					self							,    **_lowercase   ) ->						Any:







								'''simple docstring'''

								super().__init__(**_lowercase   )
								assert (
								    "encoder" in kwargs and "decoder" in kwargs
								), "Config has to be initialized with encoder and decoder config"
								snake_case_   : int						=			kwargs.pop("""encoder"""   )
								snake_case_   : List[str]						=			encoder_config.pop("""model_type"""   )
								snake_case_   : Optional[int]						=			kwargs.pop("""decoder"""   )
								snake_case_   : Tuple						=			decoder_config.pop("""model_type"""   )

								from ..auto.configuration_auto import AutoConfig

								snake_case_   : Tuple						=			AutoConfig.for_model(_lowercase							,    **_lowercase   )
								snake_case_   : str						=			AutoConfig.for_model(_lowercase							,    **_lowercase   )
								snake_case_   : Optional[Any]						=			True





		@classmethod
		def    UpperCAmelCase__							(					cls							,    _lowercase							,    _lowercase							,    **_lowercase   ) ->						PretrainedConfig:







								'''simple docstring'''

								logger.info("""Set `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config"""   )
								snake_case_   : Union[str, Any]						=			True
								snake_case_   : Tuple						=			True

								return cls(encoder=encoder_config.to_dict()							,    decoder=decoder_config.to_dict()							,    **_lowercase   )





		def    UpperCAmelCase__							(					self   ) ->						int:







								'''simple docstring'''

								snake_case_   : Union[str, Any]						=			copy.deepcopy(self.__dict__   )
								snake_case_   : Dict						=			self.encoder.to_dict()
								snake_case_   : Any						=			self.decoder.to_dict()
								snake_case_   : Optional[Any]						=			self.__class__.model_type
								return output






"""simple docstring"""





def 	__lowerCAmelCase						(		__UpperCamelCase      :			Union[str, Any]    ):


						'''simple docstring'''






						snake_case_   : int						=			[0] * len(__UpperCamelCase    )
						snake_case_   : List[str]						=			[]
						snake_case_   : Any						=			[1] * len(__UpperCamelCase    )

						for values in graph.values():
												for i in values:
																		indegree[i] += 1

						for i in range(len(__UpperCamelCase    )    ):
												if indegree[i] == 0:
																		queue.append(__UpperCamelCase    )

						while queue:
												snake_case_   : Optional[int]						=			queue.pop(0    )
												for x in graph[vertex]:
																		indegree[x] -= 1

																		if long_dist[vertex] + 1 > long_dist[x]:
																								snake_case_   : Union[str, Any]						=			long_dist[vertex] + 1

																		if indegree[x] == 0:
																								queue.append(__UpperCamelCase    )

						print(max(__UpperCamelCase    )    )


# Adjacency list of Graph
__lowerCAmelCase       :					str      					=					{0: [2, 3, 4], 1: [2, 7], 2: [5], 3: [5, 7], 4: [7], 5: [6], 6: [7], 7: []}






longest_distance(graph)

