
'''simple docstring'''







def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: dict							):



						"""simple docstring"""





						lowercase_	:     set[int]													=       set()
						# To detect a back edge, keep track of vertices currently in the recursion stack
						lowercase_	:     set[int]													=       set()
						return any(
						    node not in visited and depth_first_search(__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE							)
						    for node in graph							)
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: dict      ,      __SCREAMING_SNAKE_CASE					: int      ,      __SCREAMING_SNAKE_CASE					: set      ,      __SCREAMING_SNAKE_CASE					: set							):



						"""simple docstring"""





						visited.add(__SCREAMING_SNAKE_CASE							)
						rec_stk.add(__SCREAMING_SNAKE_CASE							)

						for node in graph[vertex]:
												if node not in visited:
																		if depth_first_search(__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE							):
																								return True
												elif node in rec_stk:
																		return True

    # The node needs to be removed from recursion stack before function ends
						rec_stk.remove(__SCREAMING_SNAKE_CASE							)
						return False


if __name__ == "__main__":
							from doctest import testmod

							testmod()





'''simple docstring'''







import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device


if is_torch_available():
							from transformers import AutoModelForSeqaSeqLM, AutoTokenizer






@require_torch
@require_sentencepiece
@require_tokenizers
class  lowerCAmelCase__   (  unittest.TestCase     ):






					@slow
					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     Dict													=       AutoModelForSeqaSeqLM.from_pretrained('''google/mt5-small'''				,							return_dict=__SCREAMING_SNAKE_CASE		).to(__SCREAMING_SNAKE_CASE		)
											lowercase_	:     Union[str, Any]													=       AutoTokenizer.from_pretrained('''google/mt5-small'''		)

											lowercase_	:     int													=       tokenizer('''Hello there'''				,							return_tensors='''pt'''		).input_ids
											lowercase_	:     Union[str, Any]													=       tokenizer('''Hi I am'''				,							return_tensors='''pt'''		).input_ids

											lowercase_	:     Union[str, Any]													=       model(input_ids.to(__SCREAMING_SNAKE_CASE		)				,							labels=labels.to(__SCREAMING_SNAKE_CASE		)		).loss
											lowercase_	:     int													=       -(labels.shape[-1] * loss.item())

											lowercase_	:     Any													=       -84.9_127
											self.assertTrue(abs(mtf_score - EXPECTED_SCORE		) < 1E-4		)



