



"""simple docstring"""





import unittest

from transformers import is_flax_available
from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow


if is_flax_available():
					import optax
					from flax.training.common_utils import onehot

					from transformers import AutoTokenizer, FlaxMTaForConditionalGeneration
					from transformers.models.ta.modeling_flax_ta import shift_tokens_right



@require_torch
@require_sentencepiece
@require_tokenizers
@require_flax
class    _lowerCAmelCase    (				unittest.TestCase		):





		"""simple docstring"""






		@slow
		def    UpperCAmelCase__							(					self   ) ->						Optional[int]:







								'''simple docstring'''

								snake_case_   : int						=			FlaxMTaForConditionalGeneration.from_pretrained("""google/mt5-small"""   )
								snake_case_   : List[Any]						=			AutoTokenizer.from_pretrained("""google/mt5-small"""   )

								snake_case_   : Dict						=			tokenizer("""Hello there"""							,    return_tensors="""np"""   ).input_ids
								snake_case_   : List[str]						=			tokenizer("""Hi I am"""							,    return_tensors="""np"""   ).input_ids

								snake_case_   : Optional[Any]						=			shift_tokens_right(_lowercase							,    model.config.pad_token_id							,    model.config.decoder_start_token_id   )

								snake_case_   : Tuple						=			model(_lowercase							,    decoder_input_ids=_lowercase   ).logits
								snake_case_   : Tuple						=			optax.softmax_cross_entropy(_lowercase							,    onehot(_lowercase							,    logits.shape[-1]   )   ).mean()

								snake_case_   : List[str]						=			-(labels.shape[-1] * loss.item())

								snake_case_   : Optional[int]						=			-84.9127
								self.assertTrue(abs(mtf_score - EXPECTED_SCORE   ) < 1E-4   )






"""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)

