
'''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 						lowercase__	(  unittest.TestCase   ):






   '''simple docstring'''







   @slow
   def       UpperCAmelCase				(			self   ):

      '''simple docstring'''







      UpperCamelCase       =  AutoModelForSeqaSeqLM.from_pretrained('''google/mt5-small''' ,   return_dict=lowerCamelCase__   ).to(lowerCamelCase__   )
      UpperCamelCase       =  AutoTokenizer.from_pretrained('''google/mt5-small'''   )

      UpperCamelCase       =  tokenizer('''Hello there''' ,   return_tensors='''pt'''   ).input_ids
      UpperCamelCase       =  tokenizer('''Hi I am''' ,   return_tensors='''pt'''   ).input_ids

      UpperCamelCase       =  model(input_ids.to(lowerCamelCase__   ) ,   labels=labels.to(lowerCamelCase__   )   ).loss
      UpperCamelCase       =  -(labels.shape[-1] * loss.item())

      UpperCamelCase       =  -84.9127
      self.assertTrue(abs(mtf_score - EXPECTED_SCORE   ) < 1e-4   )







'''simple docstring'''


from __future__ import annotations



def  __snake_case     (    _UpperCAmelCase					:       list[int]):
   UpperCamelCase       =  len(_UpperCAmelCase) // 2

   # choose the middle 3 elements
   UpperCamelCase       =  lst[m - 1 : m + 2]

   # if middle element is peak
   if three[1] > three[0] and three[1] > three[2]:
      return three[1]

   # if increasing, recurse on right
   elif three[0] < three[2]:
      if len(lst[:m]) == 2:
         m -= 1
      return peak(lst[m:])

   # decreasing
   else:
      if len(lst[:m]) == 2:
         m += 1
      return peak(lst[:m])


if __name__ == "__main__":
   import doctest

   doctest.testmod()





