
"""simple docstring"""



import unittest

import numpy as np
import torch

from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad




class 		a_    (			unittest.TestCase						):







    def   _snake_case       (      self      :							str  )		->List[Any]:






        '''simple docstring'''






        _UpperCAmelCase        = 10







    def   _snake_case       (      self      :							str  )		->str:






        '''simple docstring'''






        _UpperCAmelCase        = [1, 2, 3, 4]
        _UpperCAmelCase        = [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
        self.assertEqual(truncate_or_pad(__UpperCamelCase  ,       self.block_size  ,       0  )  ,       __UpperCamelCase  )







    def   _snake_case       (      self      :							Dict  )		->Optional[Any]:






        '''simple docstring'''






        _UpperCAmelCase        = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        _UpperCAmelCase        = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        self.assertEqual(truncate_or_pad(__UpperCamelCase  ,       self.block_size  ,       0  )  ,       __UpperCamelCase  )







    def   _snake_case       (      self      :							List[Any]  )		->Union[str, Any]:






        '''simple docstring'''






        _UpperCAmelCase        = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
        _UpperCAmelCase        = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        self.assertEqual(truncate_or_pad(__UpperCamelCase  ,       self.block_size  ,       0  )  ,       __UpperCamelCase  )







    def   _snake_case       (      self      :							Optional[int]  )		->int:






        '''simple docstring'''






        _UpperCAmelCase        = """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."""
        _UpperCAmelCase     ,_UpperCAmelCase        = process_story(__UpperCamelCase  )
        self.assertEqual(__UpperCamelCase  ,       []  )







    def   _snake_case       (      self      :							Any  )		->str:






        '''simple docstring'''






        _UpperCAmelCase        = """"""
        _UpperCAmelCase     ,_UpperCAmelCase        = process_story(__UpperCamelCase  )
        self.assertEqual(__UpperCamelCase  ,       []  )
        self.assertEqual(__UpperCamelCase  ,       []  )







    def   _snake_case       (      self      :							Any  )		->int:






        '''simple docstring'''






        _UpperCAmelCase        = (
            """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"""
        )
        _UpperCAmelCase     ,_UpperCAmelCase        = process_story(__UpperCamelCase  )

        _UpperCAmelCase        = [
            """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(__UpperCamelCase  ,       __UpperCamelCase  )

        _UpperCAmelCase        = ["""It was the best of times."""]
        self.assertEqual(__UpperCamelCase  ,       __UpperCamelCase  )







    def   _snake_case       (      self      :							Optional[Any]  )		->Any:






        '''simple docstring'''






        _UpperCAmelCase        = torch.tensor([1, 2, 3, 4]  )
        _UpperCAmelCase        = torch.tensor([1, 1, 1, 1]  )
        np.testing.assert_array_equal(build_mask(__UpperCamelCase  ,       0  ).numpy()  ,       expected.numpy()  )







    def   _snake_case       (      self      :							Dict  )		->List[Any]:






        '''simple docstring'''






        _UpperCAmelCase        = torch.tensor([1, 2, 3, 4, 23, 23, 23]  )
        _UpperCAmelCase        = torch.tensor([1, 1, 1, 1, 0, 0, 0]  )
        np.testing.assert_array_equal(build_mask(__UpperCamelCase  ,       23  ).numpy()  ,       expected.numpy()  )







    def   _snake_case       (      self      :							Union[str, Any]  )		->Tuple:






        '''simple docstring'''






        _UpperCAmelCase        = torch.tensor([8, 2, 3, 4, 1, 1, 1]  )
        _UpperCAmelCase        = torch.tensor([1, 1, 1, 1, 0, 0, 0]  )
        np.testing.assert_array_equal(build_mask(__UpperCamelCase  ,       1  ).numpy()  ,       expected.numpy()  )







    def   _snake_case       (      self      :							List[str]  )		->Any:






        '''simple docstring'''






        _UpperCAmelCase        = 1_01
        _UpperCAmelCase        = torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 1_01, 5, 6], [1, 1_01, 3, 4, 1_01, 6]]  )
        _UpperCAmelCase        = torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]]  )

        _UpperCAmelCase        = compute_token_type_ids(__UpperCamelCase  ,       __UpperCamelCase  )
        np.testing.assert_array_equal(__UpperCamelCase  ,       __UpperCamelCase  )

"""simple docstring"""



from collections import OrderedDict
from typing import Mapping

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


a       :						List[Any]       		=		logging.get_logger(__name__)

a       :						str       		=		{
    '''camembert-base''': '''https://huggingface.co/camembert-base/resolve/main/config.json''',
    '''umberto-commoncrawl-cased-v1''': (
        '''https://huggingface.co/Musixmatch/umberto-commoncrawl-cased-v1/resolve/main/config.json'''
    ),
    '''umberto-wikipedia-uncased-v1''': (
        '''https://huggingface.co/Musixmatch/umberto-wikipedia-uncased-v1/resolve/main/config.json'''
    ),
}




class 		a_    (			_UpperCAmelCase						):
    a   :					Any			     =					'camembert'







    def __init__(      self      :							Dict  ,       __UpperCamelCase      :							Union[str, Any]=3_05_22  ,       __UpperCamelCase      :							Tuple=7_68  ,       __UpperCamelCase      :							Optional[Any]=12  ,       __UpperCamelCase      :							int=12  ,       __UpperCamelCase      :							int=30_72  ,       __UpperCamelCase      :							int="gelu"  ,       __UpperCamelCase      :							Dict=0.1  ,       __UpperCamelCase      :							Dict=0.1  ,       __UpperCamelCase      :							List[Any]=5_12  ,       __UpperCamelCase      :							Optional[int]=2  ,       __UpperCamelCase      :							Dict=0.0_2  ,       __UpperCamelCase      :							Optional[int]=1e-12  ,       __UpperCamelCase      :							Optional[Any]=1  ,       __UpperCamelCase      :							int=0  ,       __UpperCamelCase      :							Optional[int]=2  ,       __UpperCamelCase      :							Optional[int]="absolute"  ,       __UpperCamelCase      :							int=True  ,       __UpperCamelCase      :							Dict=None  ,       **__UpperCamelCase      :							List[str]  ,       )		->Union[str, Any]:






        '''simple docstring'''






        super().__init__(pad_token_id=__UpperCamelCase  ,       bos_token_id=__UpperCamelCase  ,       eos_token_id=__UpperCamelCase  ,       **__UpperCamelCase  )

        _UpperCAmelCase        = vocab_size
        _UpperCAmelCase        = hidden_size
        _UpperCAmelCase        = num_hidden_layers
        _UpperCAmelCase        = num_attention_heads
        _UpperCAmelCase        = hidden_act
        _UpperCAmelCase        = intermediate_size
        _UpperCAmelCase        = hidden_dropout_prob
        _UpperCAmelCase        = attention_probs_dropout_prob
        _UpperCAmelCase        = max_position_embeddings
        _UpperCAmelCase        = type_vocab_size
        _UpperCAmelCase        = initializer_range
        _UpperCAmelCase        = layer_norm_eps
        _UpperCAmelCase        = position_embedding_type
        _UpperCAmelCase        = use_cache
        _UpperCAmelCase        = classifier_dropout







class 		a_    (			_UpperCAmelCase						):







    @property
    def   _snake_case       (      self      :							Optional[int]  )		->Mapping[str, Mapping[int, str]]:






        '''simple docstring'''






        if self.task == "multiple-choice":
            _UpperCAmelCase        = {0: """batch""", 1: """choice""", 2: """sequence"""}
        else:
            _UpperCAmelCase        = {0: """batch""", 1: """sequence"""}
        return OrderedDict(
            [
                ("""input_ids""", dynamic_axis),
                ("""attention_mask""", dynamic_axis),
            ]  )