

import torch
from torch import autograd







class 		__magic_name__     (				autograd.Function				):

   '''simple docstring'''




   @staticmethod
   def 					_UpperCAmelCase					(							lowercase_,       lowercase_,       lowercase_,       lowercase_			)				->       Tuple:






     """simple docstring"""






     a__    =inputs.numel()
     a__    =int(0.005 * nb_elems			) + 1
     if sigmoid:
       a__    =(torch.sigmoid(lowerCAmelCase__			) > threshold).type(inputs.type()			)
     else:
       a__    =(inputs > threshold).type(inputs.type()			)
     if mask.sum() < nb_min:
       # We limit the pruning so that at least 0.5% (half a percent) of the weights are remaining
       a__    =inputs.flatten().kthvalue(max(nb_elems - nb_min,       1			)			).values
       a__    =(inputs > k_threshold).type(inputs.type()			)
     return mask



   @staticmethod
   def 					_UpperCAmelCase					(							lowercase_,       lowercase_			)				->       int:






     """simple docstring"""






     return gradOutput, None, None







class 		__magic_name__     (				autograd.Function				):

   '''simple docstring'''




   @staticmethod
   def 					_UpperCAmelCase					(							lowercase_,       lowercase_,       lowercase_			)				->       Tuple:






     """simple docstring"""






     a__    =inputs.clone()
     a__, a__    =inputs.flatten().sort(descending=lowerCAmelCase__			)
     a__    =int(threshold * inputs.numel()			)

     # flat_out and mask access the same memory.
     a__    =mask.flatten()
     a__    =0
     a__    =1
     return mask



   @staticmethod
   def 					_UpperCAmelCase					(							lowercase_,       lowercase_			)				->       int:






     """simple docstring"""






     return gradOutput, None







class 		__magic_name__     (				lowerCAmelCase__				):

   '''simple docstring'''




   @staticmethod
   def 					_UpperCAmelCase					(							lowercase_,       lowercase_			)				->       str:






     """simple docstring"""






     a__    =inputs.clone()
     a__, a__    =inputs.abs().flatten().sort(descending=lowerCAmelCase__			)
     a__    =int(threshold * inputs.numel()			)

     # flat_out and mask access the same memory.
     a__    =mask.flatten()
     a__    =0
     a__    =1
     return mask

"""simple docstring"""


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


__UpperCamelCase										=     logging.get_logger(__name__)

__UpperCamelCase										=     {
    '''tau/splinter-base''': '''https://huggingface.co/tau/splinter-base/resolve/main/config.json''',
    '''tau/splinter-base-qass''': '''https://huggingface.co/tau/splinter-base-qass/resolve/main/config.json''',
    '''tau/splinter-large''': '''https://huggingface.co/tau/splinter-large/resolve/main/config.json''',
    '''tau/splinter-large-qass''': '''https://huggingface.co/tau/splinter-large-qass/resolve/main/config.json''',
    # See all Splinter models at https://huggingface.co/models?filter=splinter
}




class 					UpperCamelCase   (							lowerCAmelCase__  ):
       SCREAMING_SNAKE_CASE_						      = "splinter"







       def __init__(					self,				lowerCAmelCase__=3_0522,				lowerCAmelCase__=768,				lowerCAmelCase__=12,				lowerCAmelCase__=12,				lowerCAmelCase__=3072,				lowerCAmelCase__="gelu",				lowerCAmelCase__=0.1,				lowerCAmelCase__=0.1,				lowerCAmelCase__=512,				lowerCAmelCase__=2,				lowerCAmelCase__=0.02,				lowerCAmelCase__=1e-12,				lowerCAmelCase__=True,				lowerCAmelCase__=0,				lowerCAmelCase__=104,				**lowerCAmelCase__,				) -> Dict:
            super().__init__(pad_token_id=lowerCAmelCase__,				**lowerCAmelCase__)

            snake_case_   			=   vocab_size
            snake_case_   			=   max_position_embeddings
            snake_case_   			=   hidden_size
            snake_case_   			=   num_hidden_layers
            snake_case_   			=   num_attention_heads
            snake_case_   			=   intermediate_size
            snake_case_   			=   hidden_act
            snake_case_   			=   hidden_dropout_prob
            snake_case_   			=   attention_probs_dropout_prob
            snake_case_   			=   initializer_range
            snake_case_   			=   type_vocab_size
            snake_case_   			=   layer_norm_eps
            snake_case_   			=   use_cache
            snake_case_   			=   question_token_id

