




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


lowerCAmelCase_					    = logging.get_logger(__name__)

lowerCAmelCase_					    = {
    """funnel-transformer/small""": """https://huggingface.co/funnel-transformer/small/resolve/main/config.json""",
    """funnel-transformer/small-base""": """https://huggingface.co/funnel-transformer/small-base/resolve/main/config.json""",
    """funnel-transformer/medium""": """https://huggingface.co/funnel-transformer/medium/resolve/main/config.json""",
    """funnel-transformer/medium-base""": """https://huggingface.co/funnel-transformer/medium-base/resolve/main/config.json""",
    """funnel-transformer/intermediate""": (
        """https://huggingface.co/funnel-transformer/intermediate/resolve/main/config.json"""
    ),
    """funnel-transformer/intermediate-base""": (
        """https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/config.json"""
    ),
    """funnel-transformer/large""": """https://huggingface.co/funnel-transformer/large/resolve/main/config.json""",
    """funnel-transformer/large-base""": """https://huggingface.co/funnel-transformer/large-base/resolve/main/config.json""",
    """funnel-transformer/xlarge""": """https://huggingface.co/funnel-transformer/xlarge/resolve/main/config.json""",
    """funnel-transformer/xlarge-base""": """https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/config.json""",
}






class  _lowerCAmelCase     (  _lowercase	):
      A__		     =		'funnel'
      A__		     =		{
          'hidden_size': 'd_model',
          'num_attention_heads': 'n_head',
      }

      def __init__(   self      ,				__UpperCAmelCase=3_0522      ,				__UpperCAmelCase=[4, 4, 4]      ,				__UpperCAmelCase=None      ,				__UpperCAmelCase=2      ,				__UpperCAmelCase=768      ,				__UpperCAmelCase=12      ,				__UpperCAmelCase=64      ,				__UpperCAmelCase=3072      ,				__UpperCAmelCase="gelu_new"      ,				__UpperCAmelCase=0.1      ,				__UpperCAmelCase=0.1      ,				__UpperCAmelCase=0.0      ,				__UpperCAmelCase=0.1      ,				__UpperCAmelCase=None      ,				__UpperCAmelCase=1e-9      ,				__UpperCAmelCase="mean"      ,				__UpperCAmelCase="relative_shift"      ,				__UpperCAmelCase=True      ,				__UpperCAmelCase=True      ,				__UpperCAmelCase=True      ,				**__UpperCAmelCase      ,				):
        lowerCAmelCase__				:  Optional[Any]		       =     vocab_size
        lowerCAmelCase__				:  Union[str, Any]		       =     block_sizes
        lowerCAmelCase__				:  Optional[int]		       =     [1] * len(__UpperCAmelCase		) if block_repeats is None else block_repeats
        assert len(__UpperCAmelCase		) == len(
            self.block_repeats		), "`block_sizes` and `block_repeats` should have the same length."
        lowerCAmelCase__				:  List[str]		       =     num_decoder_layers
        lowerCAmelCase__				:  Optional[int]		       =     d_model
        lowerCAmelCase__				:  Optional[int]		       =     n_head
        lowerCAmelCase__				:  List[str]		       =     d_head
        lowerCAmelCase__				:  Optional[int]		       =     d_inner
        lowerCAmelCase__				:  Union[str, Any]		       =     hidden_act
        lowerCAmelCase__				:  Tuple		       =     hidden_dropout
        lowerCAmelCase__				:  Union[str, Any]		       =     attention_dropout
        lowerCAmelCase__				:  List[str]		       =     activation_dropout
        lowerCAmelCase__				:  Dict		       =     initializer_range
        lowerCAmelCase__				:  int		       =     initializer_std
        lowerCAmelCase__				:  str		       =     layer_norm_eps
        assert pooling_type in [
            "mean",
            "max",
        ], f"""Got {pooling_type} for `pooling_type` but only 'mean' and 'max' are supported."""
        lowerCAmelCase__				:  Optional[int]		       =     pooling_type
        assert attention_type in [
            "relative_shift",
            "factorized",
        ], f"""Got {attention_type} for `attention_type` but only 'relative_shift' and 'factorized' are supported."""
        lowerCAmelCase__				:  List[str]		       =     attention_type
        lowerCAmelCase__				:  str		       =     separate_cls
        lowerCAmelCase__				:  int		       =     truncate_seq
        lowerCAmelCase__				:  int		       =     pool_q_only

        super().__init__(**__UpperCAmelCase		)

      @property
      def 	__magic_name__(   self		):
        return sum(self.block_sizes		)

      @num_hidden_layers.setter
      def 	__magic_name__(   self      ,				__UpperCAmelCase		):
        raise NotImplementedError(
            '''This model does not support the setting of `num_hidden_layers`. Please set `block_sizes`.'''		)

      @property
      def 	__magic_name__(   self		):
        return len(self.block_sizes		)







      @num_blocks.setter
      def 	__magic_name__(   self      ,				__UpperCAmelCase		):
        raise NotImplementedError('''This model does not support the setting of `num_blocks`. Please set `block_sizes`.'''		)







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowerCAmelCase_					    = {
    """configuration_lilt""": ["""LILT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LiltConfig"""],
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCAmelCase_					    = [
         """LILT_PRETRAINED_MODEL_ARCHIVE_LIST""",
         """LiltForQuestionAnswering""",
         """LiltForSequenceClassification""",
         """LiltForTokenClassification""",
         """LiltModel""",
         """LiltPreTrainedModel""",
     ]

if TYPE_CHECKING:
     from .configuration_lilt import LILT_PRETRAINED_CONFIG_ARCHIVE_MAP, LiltConfig

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_lilt import (
              LILT_PRETRAINED_MODEL_ARCHIVE_LIST,
              LiltForQuestionAnswering,
              LiltForSequenceClassification,
              LiltForTokenClassification,
              LiltModel,
              LiltPreTrainedModel,
          )

else:
     import sys

     lowerCAmelCase_					    = _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)

