





import unittest

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


if is_torch_available():
       import torch

       from transformers import XLMRobertaModel


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







       @slow
       def 						__lowerCamelCase   (				self					:     Any      )       ->Union[str, Any]:
          lowerCamelCase__        =							XLMRobertaModel.from_pretrained('''xlm-roberta-base'''      )
          lowerCamelCase__        =							torch.tensor([[0, 5_8_1, 1_0_2_6_9, 8_3, 9_9_9_4_2, 1_3_6, 6_0_7_4_2, 2_3, 7_0, 8_0_5_8_3, 1_8_2_7_6, 2]]      )
          # The dog is cute and lives in the garden house

          lowerCamelCase__        =							torch.Size((1, 1_2, 7_6_8)      )  # batch_size, sequence_length, embedding_vector_dim
          lowerCamelCase__        =							torch.tensor(
              [[-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]]      )
          #  xlmr = torch.hub.load('pytorch/fairseq', 'xlmr.base')
          #  xlmr.eval()
          #  expected_output_values_last_dim = xlmr.extract_features(input_ids[0])[:, :, -1]
          with torch.no_grad():
             lowerCamelCase__        =							model(_lowerCAmelCase      )["""last_hidden_state"""].detach()
          self.assertEqual(output.shape		, _lowerCAmelCase      )
          # compare the actual values for a slice of last dim
          self.assertTrue(torch.allclose(output[:, :, -1]		, _lowerCAmelCase		, atol=1e-3      )      )







       @slow
       def 						__lowerCamelCase   (				self					:     Tuple      )       ->Tuple:
          lowerCamelCase__        =							XLMRobertaModel.from_pretrained('''xlm-roberta-large'''      )
          lowerCamelCase__        =							torch.tensor([[0, 5_8_1, 1_0_2_6_9, 8_3, 9_9_9_4_2, 1_3_6, 6_0_7_4_2, 2_3, 7_0, 8_0_5_8_3, 1_8_2_7_6, 2]]      )
          # The dog is cute and lives in the garden house

          lowerCamelCase__        =							torch.Size((1, 1_2, 1_0_2_4)      )  # batch_size, sequence_length, embedding_vector_dim
          lowerCamelCase__        =							torch.tensor(
              [[-0.06_99, -0.03_18, 0.07_05, -0.12_41, 0.09_99, -0.05_20, 0.10_04, -0.18_38, -0.47_04, 0.14_37, 0.08_21, 0.01_26]]      )
          #  xlmr = torch.hub.load('pytorch/fairseq', 'xlmr.large')
          #  xlmr.eval()
          #  expected_output_values_last_dim = xlmr.extract_features(input_ids[0])[:, :, -1]
          with torch.no_grad():
             lowerCamelCase__        =							model(_lowerCAmelCase      )["""last_hidden_state"""].detach()
          self.assertEqual(output.shape		, _lowerCAmelCase      )
          # compare the actual values for a slice of last dim
          self.assertTrue(torch.allclose(output[:, :, -1]		, _lowerCAmelCase		, atol=1e-3      )      )










def 	_a						(   UpperCAmelCase      ,  UpperCAmelCase					)    ->    Dict:







   """simple docstring"""
   if b == 0:
      return 1
   if (b % 2) == 0:
      return actual_power(UpperCAmelCase      ,  int(b / 2					)					) * actual_power(UpperCAmelCase      ,  int(b / 2					)					)
   else:
      return a * actual_power(UpperCAmelCase      ,  int(b / 2					)					) * actual_power(UpperCAmelCase      ,  int(b / 2					)					)



def 	_a						(   UpperCAmelCase      ,  UpperCAmelCase					)    ->    float:







   """simple docstring"""
   if b < 0:
      return 1 / actual_power(UpperCAmelCase      ,  UpperCAmelCase					)
   return actual_power(UpperCAmelCase      ,  UpperCAmelCase					)


if __name__ == "__main__":
       print(power(-2, -3))



