


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      UpperCamelCase	(   self)			->  List[Any]:




           """simple docstring"""

           _lowercase			:				str 						=						AutoModelForSeqaSeqLM.from_pretrained('google/mt5-small', return_dict=lowerCamelCase).to(lowerCamelCase)
           _lowercase			:				str 						=						AutoTokenizer.from_pretrained('google/mt5-small')

           _lowercase			:				Any 						=						tokenizer('Hello there', return_tensors='pt').input_ids
           _lowercase			:				Optional[Any] 						=						tokenizer('Hi I am', return_tensors='pt').input_ids

           _lowercase			:				Optional[Any] 						=						model(input_ids.to(lowerCamelCase), labels=labels.to(lowerCamelCase)).loss
           _lowercase			:				Union[str, Any] 						=						-(labels.shape[-1] * loss.item())

           _lowercase			:				Union[str, Any] 						=						-8_4.9_1_2_7
           self.assertTrue(abs(mtf_score - EXPECTED_SCORE) < 1E-4)






from __future__ import annotations



def 							UpperCamelCase_( lowerCamelCase_					)       ->		float:
    if not nums:
        raise ValueError('List is empty'					)
    return sum(lowerCamelCase_					) / len(lowerCamelCase_					)


if __name__ == "__main__":
 import doctest

 doctest.testmod()


