"""simple docstring"""


import torch
from torch import autograd




class 					UpperCamelCase   (							autograd.Function  ):







       @staticmethod
       def 						a_		(					lowerCAmelCase__,				lowerCAmelCase__,				lowerCAmelCase__,				lowerCAmelCase__) -> Tuple:
            snake_case_   			=   inputs.numel()
            snake_case_   			=   int(0.005 * nb_elems) + 1
            if sigmoid:
                 snake_case_   			=   (torch.sigmoid(lowerCAmelCase__) > threshold).type(inputs.type())
            else:
                 snake_case_   			=   (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
                 snake_case_   			=   inputs.flatten().kthvalue(max(nb_elems - nb_min,				1)).values
                 snake_case_   			=   (inputs > k_threshold).type(inputs.type())
            return mask







       @staticmethod
       def 						a_		(					lowerCAmelCase__,				lowerCAmelCase__) -> int:
            return gradOutput, None, None




class 					UpperCamelCase   (							autograd.Function  ):







       @staticmethod
       def 						a_		(					lowerCAmelCase__,				lowerCAmelCase__,				lowerCAmelCase__) -> Tuple:
            snake_case_   			=   inputs.clone()
            snake_case_			,      snake_case_   			=   inputs.flatten().sort(descending=lowerCAmelCase__)
            snake_case_   			=   int(threshold * inputs.numel())

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







       @staticmethod
       def 						a_		(					lowerCAmelCase__,				lowerCAmelCase__) -> int:
            return gradOutput, None




class 					UpperCamelCase   (							lowerCAmelCase__  ):







       @staticmethod
       def 						a_		(					lowerCAmelCase__,				lowerCAmelCase__) -> str:
            snake_case_   			=   inputs.clone()
            snake_case_			,      snake_case_   			=   inputs.abs().flatten().sort(descending=lowerCAmelCase__)
            snake_case_   			=   int(threshold * inputs.numel())

            # flat_out and mask access the same memory.
            snake_case_   			=   mask.flatten()
            snake_case_   			=   0
            snake_case_   			=   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

