






"""simple docstring"""


import os
import sys
from contextlib import contextmanager


# Windows only
if os.name == "nt":
   import ctypes
   import msvcrt  # noqa






   class 						snake_case  (  ctypes.Structure	):
       # _fields is a specific attr expected by ctypes
       __magic_name__   					=					[('''size''', ctypes.c_int), ('''visible''', ctypes.c_byte)]




def       snake_case  ():







  '''simple docstring'''

  if os.name == "nt":
    a					:      Any    =       CursorInfo()
    a					:      str    =       ctypes.windll.kernelaa.GetStdHandle(-1_1				)
    ctypes.windll.kernelaa.GetConsoleCursorInfo(__A     ,      ctypes.byref(__A				)				)
    a					:      Union[str, Any]    =       False
    ctypes.windll.kernelaa.SetConsoleCursorInfo(__A     ,      ctypes.byref(__A				)				)
  elif os.name == "posix":
    sys.stdout.write('\033[?25l'				)
    sys.stdout.flush()




def       snake_case  ():







  '''simple docstring'''

  if os.name == "nt":
    a					:      str    =       CursorInfo()
    a					:      List[str]    =       ctypes.windll.kernelaa.GetStdHandle(-1_1				)
    ctypes.windll.kernelaa.GetConsoleCursorInfo(__A     ,      ctypes.byref(__A				)				)
    a					:      Optional[Any]    =       True
    ctypes.windll.kernelaa.SetConsoleCursorInfo(__A     ,      ctypes.byref(__A				)				)
  elif os.name == "posix":
    sys.stdout.write('\033[?25h'				)
    sys.stdout.flush()






@contextmanager
def       snake_case  ():







  '''simple docstring'''

  try:
    hide_cursor()
    yield
  finally:
    show_cursor()












"""simple docstring"""


import unittest

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


if is_flax_available():
   import jax.numpy as jnp

   from transformers import FlaxXLMRobertaModel






@require_sentencepiece
@require_tokenizers
@require_flax
class 						snake_case  (  unittest.TestCase	):





    @slow
    def     lowerCamelCase__				(							self     : Optional[Any]      ):


      '''simple docstring'''




      a					:      Optional[int]    =       FlaxXLMRobertaModel.from_pretrained('xlm-roberta-base'      )
      a					:      int    =       AutoTokenizer.from_pretrained('xlm-roberta-base'      )
      a					:      int    =       'The dog is cute and lives in the garden house'
      a					:      List[Any]    =       jnp.array([tokenizer.encode(A      )]      )

      a					:      int    =       (1, 1_2, 7_6_8)  # batch_size, sequence_length, embedding_vector_dim
      a					:      Dict    =       jnp.array(
          [[-0.01_01, 0.12_18, -0.08_03, 0.08_01, 0.13_27, 0.07_76, -0.12_15, 0.23_83, 0.33_38, 0.31_06, 0.03_00, 0.02_52]]      )

      a					:      Any    =       model(A      )['last_hidden_state']
      self.assertEqual(output.shape    ,		A      )
      # compare the actual values for a slice of last dim
      self.assertTrue(jnp.allclose(output[:, :, -1]    ,		A    ,		atol=1E-3      )      )




