



import unittest

import numpy as np

from transformers.testing_utils import require_flax, require_tf, require_torch
from transformers.utils import (
    expand_dims,
    flatten_dict,
    is_flax_available,
    is_tf_available,
    is_torch_available,
    reshape,
    squeeze,
    transpose,
)


if is_flax_available():
     import jax.numpy as jnp

if is_tf_available():
     import tensorflow as tf

if is_torch_available():
     import torch



class 		_lowercase		(       unittest.TestCase	):

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


    """simple docstring"""






    a						=		{
        "task_specific_params": {
            "summarization": {"length_penalty": 1.0, "max_length": 128, "min_length": 12, "num_beams": 4},
            "summarization_cnn": {"length_penalty": 2.0, "max_length": 142, "min_length": 56, "num_beams": 4},
            "summarization_xsum": {"length_penalty": 1.0, "max_length": 62, "min_length": 11, "num_beams": 6},
        }
    }
    a						=		{
        "task_specific_params.summarization.length_penalty": 1.0,
        "task_specific_params.summarization.max_length": 128,
        "task_specific_params.summarization.min_length": 12,
        "task_specific_params.summarization.num_beams": 4,
        "task_specific_params.summarization_cnn.length_penalty": 2.0,
        "task_specific_params.summarization_cnn.max_length": 142,
        "task_specific_params.summarization_cnn.min_length": 56,
        "task_specific_params.summarization_cnn.num_beams": 4,
        "task_specific_params.summarization_xsum.length_penalty": 1.0,
        "task_specific_params.summarization_xsum.max_length": 62,
        "task_specific_params.summarization_xsum.min_length": 11,
        "task_specific_params.summarization_xsum.num_beams": 6,
    }

    self.assertEqual(flatten_dict(__lowerCAmelCase							)							,   __lowerCAmelCase							)

   def 		A							(      self			:       int							)       ->				List[str]:


    """simple docstring"""






    a						=		np.random.randn(3							,   4							)
    self.assertTrue(np.allclose(transpose(__lowerCAmelCase							)							,   x.transpose()							)							)

    a						=		np.random.randn(3							,   4							,   5							)
    self.assertTrue(np.allclose(transpose(__lowerCAmelCase							,   axes=(1, 2, 0)							)							,   x.transpose((1, 2, 0)							)							)							)

   @require_torch
   def 		A							(      self			:       Dict							)       ->				Optional[int]:


    """simple docstring"""






    a						=		np.random.randn(3							,   4							)
    a						=		torch.tensor(__lowerCAmelCase							)
    self.assertTrue(np.allclose(transpose(__lowerCAmelCase							)							,   transpose(__lowerCAmelCase							).numpy()							)							)

    a						=		np.random.randn(3							,   4							,   5							)
    a						=		torch.tensor(__lowerCAmelCase							)
    self.assertTrue(np.allclose(transpose(__lowerCAmelCase							,   axes=(1, 2, 0)							)							,   transpose(__lowerCAmelCase							,   axes=(1, 2, 0)							).numpy()							)							)

   @require_tf
   def 		A							(      self			:       str							)       ->				Optional[int]:


    """simple docstring"""






    a						=		np.random.randn(3							,   4							)
    a						=		tf.constant(__lowerCAmelCase							)
    self.assertTrue(np.allclose(transpose(__lowerCAmelCase							)							,   transpose(__lowerCAmelCase							).numpy()							)							)

    a						=		np.random.randn(3							,   4							,   5							)
    a						=		tf.constant(__lowerCAmelCase							)
    self.assertTrue(np.allclose(transpose(__lowerCAmelCase							,   axes=(1, 2, 0)							)							,   transpose(__lowerCAmelCase							,   axes=(1, 2, 0)							).numpy()							)							)

   @require_flax
   def 		A							(      self			:       int							)       ->				Union[str, Any]:


    """simple docstring"""






    a						=		np.random.randn(3							,   4							)
    a						=		jnp.array(__lowerCAmelCase							)
    self.assertTrue(np.allclose(transpose(__lowerCAmelCase							)							,   np.asarray(transpose(__lowerCAmelCase							)							)							)							)

    a						=		np.random.randn(3							,   4							,   5							)
    a						=		jnp.array(__lowerCAmelCase							)
    self.assertTrue(np.allclose(transpose(__lowerCAmelCase							,   axes=(1, 2, 0)							)							,   np.asarray(transpose(__lowerCAmelCase							,   axes=(1, 2, 0)							)							)							)							)

   def 		A							(      self			:       int							)       ->				Union[str, Any]:


    """simple docstring"""






    a						=		np.random.randn(3							,   4							)
    self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,   (4, 3)							)							,   np.reshape(__lowerCAmelCase							,   (4, 3)							)							)							)

    a						=		np.random.randn(3							,   4							,   5							)
    self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,   (12, 5)							)							,   np.reshape(__lowerCAmelCase							,   (12, 5)							)							)							)

   @require_torch
   def 		A							(      self			:       Dict							)       ->				Optional[int]:


    """simple docstring"""






    a						=		np.random.randn(3							,   4							)
    a						=		torch.tensor(__lowerCAmelCase							)
    self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,   (4, 3)							)							,   reshape(__lowerCAmelCase							,   (4, 3)							).numpy()							)							)

    a						=		np.random.randn(3							,   4							,   5							)
    a						=		torch.tensor(__lowerCAmelCase							)
    self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,   (12, 5)							)							,   reshape(__lowerCAmelCase							,   (12, 5)							).numpy()							)							)

   @require_tf
   def 		A							(      self			:       Any							)       ->				List[str]:


    """simple docstring"""






    a						=		np.random.randn(3							,   4							)
    a						=		tf.constant(__lowerCAmelCase							)
    self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,   (4, 3)							)							,   reshape(__lowerCAmelCase							,   (4, 3)							).numpy()							)							)

    a						=		np.random.randn(3							,   4							,   5							)
    a						=		tf.constant(__lowerCAmelCase							)
    self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,   (12, 5)							)							,   reshape(__lowerCAmelCase							,   (12, 5)							).numpy()							)							)

   @require_flax
   def 		A							(      self			:       Optional[int]							)       ->				Any:


    """simple docstring"""






    a						=		np.random.randn(3							,   4							)
    a						=		jnp.array(__lowerCAmelCase							)
    self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,   (4, 3)							)							,   np.asarray(reshape(__lowerCAmelCase							,   (4, 3)							)							)							)							)

    a						=		np.random.randn(3							,   4							,   5							)
    a						=		jnp.array(__lowerCAmelCase							)
    self.assertTrue(np.allclose(reshape(__lowerCAmelCase							,   (12, 5)							)							,   np.asarray(reshape(__lowerCAmelCase							,   (12, 5)							)							)							)							)

   def 		A							(      self			:       Union[str, Any]							)       ->				Optional[int]:


    """simple docstring"""






    a						=		np.random.randn(1							,   3							,   4							)
    self.assertTrue(np.allclose(squeeze(__lowerCAmelCase							)							,   np.squeeze(__lowerCAmelCase							)							)							)

    a						=		np.random.randn(1							,   4							,   1							,   5							)
    self.assertTrue(np.allclose(squeeze(__lowerCAmelCase							,   axis=2							)							,   np.squeeze(__lowerCAmelCase							,   axis=2							)							)							)

   @require_torch
   def 		A							(      self			:       Tuple							)       ->				Union[str, Any]:


    """simple docstring"""






    a						=		np.random.randn(1							,   3							,   4							)
    a						=		torch.tensor(__lowerCAmelCase							)
    self.assertTrue(np.allclose(squeeze(__lowerCAmelCase							)							,   squeeze(__lowerCAmelCase							).numpy()							)							)

    a						=		np.random.randn(1							,   4							,   1							,   5							)
    a						=		torch.tensor(__lowerCAmelCase							)
    self.assertTrue(np.allclose(squeeze(__lowerCAmelCase							,   axis=2							)							,   squeeze(__lowerCAmelCase							,   axis=2							).numpy()							)							)

   @require_tf
   def 		A							(      self			:       Tuple							)       ->				Any:


    """simple docstring"""






    a						=		np.random.randn(1							,   3							,   4							)
    a						=		tf.constant(__lowerCAmelCase							)
    self.assertTrue(np.allclose(squeeze(__lowerCAmelCase							)							,   squeeze(__lowerCAmelCase							).numpy()							)							)

    a						=		np.random.randn(1							,   4							,   1							,   5							)
    a						=		tf.constant(__lowerCAmelCase							)
    self.assertTrue(np.allclose(squeeze(__lowerCAmelCase							,   axis=2							)							,   squeeze(__lowerCAmelCase							,   axis=2							).numpy()							)							)

   @require_flax
   def 		A							(      self			:       str							)       ->				Optional[Any]:


    """simple docstring"""






    a						=		np.random.randn(1							,   3							,   4							)
    a						=		jnp.array(__lowerCAmelCase							)
    self.assertTrue(np.allclose(squeeze(__lowerCAmelCase							)							,   np.asarray(squeeze(__lowerCAmelCase							)							)							)							)

    a						=		np.random.randn(1							,   4							,   1							,   5							)
    a						=		jnp.array(__lowerCAmelCase							)
    self.assertTrue(np.allclose(squeeze(__lowerCAmelCase							,   axis=2							)							,   np.asarray(squeeze(__lowerCAmelCase							,   axis=2							)							)							)							)

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


    """simple docstring"""






    a						=		np.random.randn(3							,   4							)
    self.assertTrue(np.allclose(expand_dims(__lowerCAmelCase							,   axis=1							)							,   np.expand_dims(__lowerCAmelCase							,   axis=1							)							)							)

   @require_torch
   def 		A							(      self			:       Tuple							)       ->				List[Any]:


    """simple docstring"""






    a						=		np.random.randn(3							,   4							)
    a						=		torch.tensor(__lowerCAmelCase							)
    self.assertTrue(np.allclose(expand_dims(__lowerCAmelCase							,   axis=1							)							,   expand_dims(__lowerCAmelCase							,   axis=1							).numpy()							)							)

   @require_tf
   def 		A							(      self			:       List[Any]							)       ->				Dict:


    """simple docstring"""






    a						=		np.random.randn(3							,   4							)
    a						=		tf.constant(__lowerCAmelCase							)
    self.assertTrue(np.allclose(expand_dims(__lowerCAmelCase							,   axis=1							)							,   expand_dims(__lowerCAmelCase							,   axis=1							).numpy()							)							)




   @require_flax
   def 		A							(      self			:       List[str]							)       ->				Optional[Any]:


    """simple docstring"""






    a						=		np.random.randn(3							,   4							)
    a						=		jnp.array(__lowerCAmelCase							)
    self.assertTrue(np.allclose(expand_dims(__lowerCAmelCase							,   axis=1							)							,   np.asarray(expand_dims(__lowerCAmelCase							,   axis=1							)							)							)							)









from ...configuration_utils import PretrainedConfig
from ...utils import logging


A_		:     Any        =     logging.get_logger(__name__)

A_		:     Optional[int]        =     {
    '''SCUT-DLVCLab/lilt-roberta-en-base''': (
        '''https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/config.json'''
    ),
}



class 		_lowercase		(       UpperCAmelCase__	):
   _UpperCAmelCase     	=			'''lilt'''

   def __init__(      self			:       Union[str, Any]							,   __lowerCAmelCase			:       Optional[Any]=3_0522							,   __lowerCAmelCase			:       str=768							,   __lowerCAmelCase			:       Any=12							,   __lowerCAmelCase			:       Optional[Any]=12							,   __lowerCAmelCase			:       List[Any]=3072							,   __lowerCAmelCase			:       Dict="gelu"							,   __lowerCAmelCase			:       int=0.1							,   __lowerCAmelCase			:       Union[str, Any]=0.1							,   __lowerCAmelCase			:       List[str]=512							,   __lowerCAmelCase			:       Optional[int]=2							,   __lowerCAmelCase			:       int=0.0_2							,   __lowerCAmelCase			:       Union[str, Any]=1E-12							,   __lowerCAmelCase			:       Tuple=0							,   __lowerCAmelCase			:       List[Any]="absolute"							,   __lowerCAmelCase			:       int=None							,   __lowerCAmelCase			:       Dict=4							,   __lowerCAmelCase			:       Dict=1024							,   **__lowerCAmelCase			:       Dict							,   )       ->				int:


    """simple docstring"""






    super().__init__(pad_token_id=__lowerCAmelCase							,   **__lowerCAmelCase							)

    a						=		vocab_size
    a						=		hidden_size
    a						=		num_hidden_layers
    a						=		num_attention_heads
    a						=		hidden_act
    a						=		intermediate_size
    a						=		hidden_dropout_prob
    a						=		attention_probs_dropout_prob
    a						=		max_position_embeddings
    a						=		type_vocab_size
    a						=		initializer_range
    a						=		layer_norm_eps
    a						=		position_embedding_type
    a						=		classifier_dropout
    a						=		channel_shrink_ratio
    a						=		max_ad_position_embeddings

