





from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


_snake_case  :   Optional[int]						   =  logging.get_logger(__name__)

_snake_case  :   Optional[Any]						   =  {
    'facebook/xlm-roberta-xl': 'https://huggingface.co/facebook/xlm-roberta-xl/resolve/main/config.json',
    'facebook/xlm-roberta-xxl': 'https://huggingface.co/facebook/xlm-roberta-xxl/resolve/main/config.json',
    # See all XLM-RoBERTa-XL models at https://huggingface.co/models?filter=xlm-roberta-xl
}



class     _UpperCAmelCase   (   _lowerCamelCase   ):

   """simple docstring"""


   a_      =			"""xlm-roberta-xl"""






   def __init__(    self			:		Optional[Any] ,  lowerCAmelCase_			:		Optional[Any]=2_5_0_8_8_0 ,  lowerCAmelCase_			:		Tuple=2_5_6_0 ,  lowerCAmelCase_			:		str=3_6 ,  lowerCAmelCase_			:		List[str]=3_2 ,  lowerCAmelCase_			:		Optional[Any]=1_0_2_4_0 ,  lowerCAmelCase_			:		List[str]="gelu" ,  lowerCAmelCase_			:		Union[str, Any]=0.1 ,  lowerCAmelCase_			:		Union[str, Any]=0.1 ,  lowerCAmelCase_			:		str=5_1_4 ,  lowerCAmelCase_			:		Any=1 ,  lowerCAmelCase_			:		Optional[Any]=0.02 ,  lowerCAmelCase_			:		Dict=1e-05 ,  lowerCAmelCase_			:		List[Any]=1 ,  lowerCAmelCase_			:		str=0 ,  lowerCAmelCase_			:		Dict=2 ,  lowerCAmelCase_			:		Optional[Any]="absolute" ,  lowerCAmelCase_			:		str=True ,  lowerCAmelCase_			:		str=None ,  **lowerCAmelCase_			:		Tuple ,  )							->						List[str]:
      super().__init__(pad_token_id=lowercase_ ,  bos_token_id=lowercase_ ,  eos_token_id=lowercase_ ,  **lowercase_					)
      __lowerCAmelCase							     =     vocab_size
      __lowerCAmelCase							     =     hidden_size
      __lowerCAmelCase							     =     num_hidden_layers
      __lowerCAmelCase							     =     num_attention_heads
      __lowerCAmelCase							     =     hidden_act
      __lowerCAmelCase							     =     intermediate_size
      __lowerCAmelCase							     =     hidden_dropout_prob
      __lowerCAmelCase							     =     attention_probs_dropout_prob
      __lowerCAmelCase							     =     max_position_embeddings
      __lowerCAmelCase							     =     type_vocab_size
      __lowerCAmelCase							     =     initializer_range
      __lowerCAmelCase							     =     layer_norm_eps
      __lowerCAmelCase							     =     position_embedding_type
      __lowerCAmelCase							     =     use_cache
      __lowerCAmelCase							     =     classifier_dropout





class     _UpperCAmelCase   (   _lowerCamelCase   ):

   """simple docstring"""


   @property
   def     lowercase		(    self			:		Optional[Any]					)							->						int:
      if self.task == "multiple-choice":
         __lowerCAmelCase							     =     {0: 'batch', 1: 'choice', 2: 'sequence'}
      else:
         __lowerCAmelCase							     =     {0: 'batch', 1: 'sequence'}
      return OrderedDict(
          [
              ('input_ids', dynamic_axis),
              ('attention_mask', dynamic_axis),
          ]					)








import unittest

import numpy as np
import torch

from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad



class     _UpperCAmelCase   (   unittest.TestCase   ):

  """simple docstring"""


  def     lowercase		(    self			:		Any					)							->						Optional[int]:
     __lowerCAmelCase							     =     1_0






  def     lowercase		(    self			:		int					)							->						Union[str, Any]:
     __lowerCAmelCase							     =     [1, 2, 3, 4]
     __lowerCAmelCase							     =     [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
     self.assertEqual(truncate_or_pad(lowerCAmelCase_ ,  self.block_size ,  0					) ,  lowerCAmelCase_					)






  def     lowercase		(    self			:		Optional[Any]					)							->						List[str]:
     __lowerCAmelCase							     =     [1, 2, 3, 4, 5, 6, 7, 8, 9, 1_0]
     __lowerCAmelCase							     =     [1, 2, 3, 4, 5, 6, 7, 8, 9, 1_0]
     self.assertEqual(truncate_or_pad(lowerCAmelCase_ ,  self.block_size ,  0					) ,  lowerCAmelCase_					)






  def     lowercase		(    self			:		Any					)							->						Optional[Any]:
     __lowerCAmelCase							     =     [1, 2, 3, 4, 5, 6, 7, 8, 9, 1_0, 1_1, 1_2, 1_3]
     __lowerCAmelCase							     =     [1, 2, 3, 4, 5, 6, 7, 8, 9, 1_0]
     self.assertEqual(truncate_or_pad(lowerCAmelCase_ ,  self.block_size ,  0					) ,  lowerCAmelCase_					)






  def     lowercase		(    self			:		List[str]					)							->						Any:
     __lowerCAmelCase							     =     'It was the year of Our Lord one thousand seven hundred and\n        seventy-five.\n\nSpiritual revelations were conceded to England at that\n        favoured period, as at this.'
     __lowerCAmelCase     ,     __lowerCAmelCase							     =     process_story(lowerCAmelCase_					)
     self.assertEqual(lowerCAmelCase_ ,  []					)






  def     lowercase		(    self			:		Any					)							->						str:
     __lowerCAmelCase							     =     ''
     __lowerCAmelCase     ,     __lowerCAmelCase							     =     process_story(lowerCAmelCase_					)
     self.assertEqual(lowerCAmelCase_ ,  []					)
     self.assertEqual(lowerCAmelCase_ ,  []					)






  def     lowercase		(    self			:		int					)							->						int:
     __lowerCAmelCase							     =     (
         'It was the year of Our Lord one thousand seven hundred and '
         'seventy-five\n\nSpiritual revelations were conceded to England '
         'at that favoured period, as at this.\n@highlight\n\nIt was the best of times'
     )
     __lowerCAmelCase     ,     __lowerCAmelCase							     =     process_story(lowerCAmelCase_					)

     __lowerCAmelCase							     =     [
         'It was the year of Our Lord one thousand seven hundred and seventy-five.',
         'Spiritual revelations were conceded to England at that favoured period, as at this.',
     ]
     self.assertEqual(lowerCAmelCase_ ,  lowerCAmelCase_					)

     __lowerCAmelCase							     =     ['It was the best of times.']
     self.assertEqual(lowerCAmelCase_ ,  lowerCAmelCase_					)






  def     lowercase		(    self			:		Dict					)							->						Any:
     __lowerCAmelCase							     =     torch.tensor([1, 2, 3, 4]					)
     __lowerCAmelCase							     =     torch.tensor([1, 1, 1, 1]					)
     np.testing.assert_array_equal(build_mask(lowerCAmelCase_ ,  0					).numpy() ,  expected.numpy()					)






  def     lowercase		(    self			:		List[Any]					)							->						Optional[int]:
     __lowerCAmelCase							     =     torch.tensor([1, 2, 3, 4, 2_3, 2_3, 2_3]					)
     __lowerCAmelCase							     =     torch.tensor([1, 1, 1, 1, 0, 0, 0]					)
     np.testing.assert_array_equal(build_mask(lowerCAmelCase_ ,  2_3					).numpy() ,  expected.numpy()					)






  def     lowercase		(    self			:		str					)							->						List[Any]:
     __lowerCAmelCase							     =     torch.tensor([8, 2, 3, 4, 1, 1, 1]					)
     __lowerCAmelCase							     =     torch.tensor([1, 1, 1, 1, 0, 0, 0]					)
     np.testing.assert_array_equal(build_mask(lowerCAmelCase_ ,  1					).numpy() ,  expected.numpy()					)






  def     lowercase		(    self			:		Optional[Any]					)							->						Optional[int]:
     __lowerCAmelCase							     =     1_0_1
     __lowerCAmelCase							     =     torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 1_0_1, 5, 6], [1, 1_0_1, 3, 4, 1_0_1, 6]]					)
     __lowerCAmelCase							     =     torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]]					)

     __lowerCAmelCase							     =     compute_token_type_ids(lowerCAmelCase_ ,  lowerCAmelCase_					)
     np.testing.assert_array_equal(lowerCAmelCase_ ,  lowerCAmelCase_					)

