


def  UpperCamelCase__	(    SCREAMING_SNAKE_CASE__     ,			SCREAMING_SNAKE_CASE__		):
 __lowerCamelCase						:				List[str]						   =		0
 while b > 0:
  if b & 1:
   res += a

  a += a
  b >>= 1

 return res



def  UpperCamelCase__	(    SCREAMING_SNAKE_CASE__     ,			SCREAMING_SNAKE_CASE__     ,			SCREAMING_SNAKE_CASE__		):
 __lowerCamelCase						:				Tuple						   =		0
 while b > 0:
  if b & 1:
   __lowerCamelCase						:				Optional[Any]						   =		((res % c) + (a % c)) % c

  a += a
  b >>= 1

 return res








'''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      lowerCAmelCase			(   self							:			Union[str, Any]						)->	Optional[Any]:
        snake_case 						=   FlaxMTaForConditionalGeneration.from_pretrained("""google/mt5-small"""						)
        snake_case 						=   AutoTokenizer.from_pretrained("""google/mt5-small"""						)

        snake_case 						=   tokenizer("""Hello there"""   ,       return_tensors="""np"""						).input_ids
        snake_case 						=   tokenizer("""Hi I am"""   ,       return_tensors="""np"""						).input_ids

        snake_case 						=   shift_tokens_right(__snake_case   ,       model.config.pad_token_id   ,       model.config.decoder_start_token_id						)

        snake_case 						=   model(__snake_case   ,       decoder_input_ids=__snake_case						).logits
        snake_case 						=   optax.softmax_cross_entropy(__snake_case   ,       onehot(__snake_case   ,       logits.shape[-1]						)						).mean()

        snake_case 						=   -(labels.shape[-1] * loss.item())

        snake_case 						=   -84.91_27
        self.assertTrue(abs(mtf_score - EXPECTED_SCORE						) < 1e-4						)

