


from collections import OrderedDict
from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union

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


if TYPE_CHECKING:
   from ...onnx.config import PatchingSpec
   from ...tokenization_utils_base import PreTrainedTokenizerBase


_snake_case          =							logging.get_logger(__name__)

_snake_case          =							{
    "allenai/longformer-base-4096": "https://huggingface.co/allenai/longformer-base-4096/resolve/main/config.json",
    "allenai/longformer-large-4096": "https://huggingface.co/allenai/longformer-large-4096/resolve/main/config.json",
    "allenai/longformer-large-4096-finetuned-triviaqa": (
        "https://huggingface.co/allenai/longformer-large-4096-finetuned-triviaqa/resolve/main/config.json"
    ),
    "allenai/longformer-base-4096-extra.pos.embd.only": (
        "https://huggingface.co/allenai/longformer-base-4096-extra.pos.embd.only/resolve/main/config.json"
    ),
    "allenai/longformer-large-4096-extra.pos.embd.only": (
        "https://huggingface.co/allenai/longformer-large-4096-extra.pos.embd.only/resolve/main/config.json"
    ),
}



class   _a      (      __UpperCAmelCase ):
    a_    :				Tuple             =    """longformer"""
    def __init__( self							:					str							,					SCREAMING_SNAKE_CASE__							:					Optional[Any] = 5_12							,					SCREAMING_SNAKE_CASE__							:					Optional[Any] = 2							,					SCREAMING_SNAKE_CASE__							:					List[str] = 1							,					SCREAMING_SNAKE_CASE__							:					Tuple = 0							,					SCREAMING_SNAKE_CASE__							:					int = 2							,					SCREAMING_SNAKE_CASE__							:					Any = 3_05_22							,					SCREAMING_SNAKE_CASE__							:					Tuple = 7_68							,					SCREAMING_SNAKE_CASE__							:					List[Any] = 12							,					SCREAMING_SNAKE_CASE__							:					Any = 12							,					SCREAMING_SNAKE_CASE__							:					Dict = 30_72							,					SCREAMING_SNAKE_CASE__							:					Optional[int] = "gelu"							,					SCREAMING_SNAKE_CASE__							:					Optional[Any] = 0.1							,					SCREAMING_SNAKE_CASE__							:					List[str] = 0.1							,					SCREAMING_SNAKE_CASE__							:					str = 5_12							,					SCREAMING_SNAKE_CASE__							:					List[str] = 2							,					SCREAMING_SNAKE_CASE__							:					Any = 0.02							,					SCREAMING_SNAKE_CASE__							:					Tuple = 1e-12							,					SCREAMING_SNAKE_CASE__							:					int = False							,					**SCREAMING_SNAKE_CASE__							:					int							,					):
          super().__init__(pad_token_id=UpperCAmelCase_							,					**UpperCAmelCase_				)

          lowerCamelCase__           =		attention_window
          lowerCamelCase__           =		sep_token_id
          lowerCamelCase__           =		bos_token_id
          lowerCamelCase__           =		eos_token_id
          lowerCamelCase__           =		vocab_size
          lowerCamelCase__           =		hidden_size
          lowerCamelCase__           =		num_hidden_layers
          lowerCamelCase__           =		num_attention_heads
          lowerCamelCase__           =		hidden_act
          lowerCamelCase__           =		intermediate_size
          lowerCamelCase__           =		hidden_dropout_prob
          lowerCamelCase__           =		attention_probs_dropout_prob
          lowerCamelCase__           =		max_position_embeddings
          lowerCamelCase__           =		type_vocab_size
          lowerCamelCase__           =		initializer_range
          lowerCamelCase__           =		layer_norm_eps
          lowerCamelCase__           =		onnx_export





class   _a      (      __UpperCAmelCase ):
    def __init__( self							:					Union[str, Any]							,					SCREAMING_SNAKE_CASE__							:					List[str]							,					SCREAMING_SNAKE_CASE__							:					List[Any] = "default"							,					SCREAMING_SNAKE_CASE__							:					Union[str, Any] = None				):
          super().__init__(UpperCAmelCase_							,					UpperCAmelCase_							,					UpperCAmelCase_				)
          lowerCamelCase__           =		True
    @property
    def      _UpperCamelCase       ( self							:					Union[str, Any]				):
          if self.task == "multiple-choice":
                lowerCamelCase__           =		{0: 'batch', 1: 'choice', 2: 'sequence'}
          else:
                lowerCamelCase__           =		{0: 'batch', 1: 'sequence'}
          return OrderedDict(
              [
                  ('input_ids', dynamic_axis),
                  ('attention_mask', dynamic_axis),
                  ('global_attention_mask', dynamic_axis),
              ]				)
    @property
    def      _UpperCamelCase       ( self							:					Any				):
          lowerCamelCase__           =		super().outputs
          if self.task == "default":
                lowerCamelCase__           =		{0: 'batch'}
          return outputs
    @property
    def      _UpperCamelCase       ( self							:					Optional[Any]				):
          return 1e-4
    @property
    def      _UpperCamelCase       ( self							:					str				):
          # needs to be >= 14 to support tril operator
          return max(super().default_onnx_opset							,					14				)


    def      _UpperCamelCase       ( self							:					Optional[Any]							,					SCREAMING_SNAKE_CASE__							:					Tuple							,					SCREAMING_SNAKE_CASE__							:					Optional[Any] = -1							,					SCREAMING_SNAKE_CASE__							:					List[str] = -1							,					SCREAMING_SNAKE_CASE__							:					Optional[int] = False							,					SCREAMING_SNAKE_CASE__							:					int = None							,					):
          lowerCamelCase__           =		super().generate_dummy_inputs(
              preprocessor=UpperCAmelCase_							,					batch_size=UpperCAmelCase_							,					seq_length=UpperCAmelCase_							,					is_pair=UpperCAmelCase_							,					framework=UpperCAmelCase_				)
          import torch

          # for some reason, replacing this code by inputs["global_attention_mask"] = torch.randint(2, inputs["input_ids"].shape, dtype=torch.int64)
          # makes the export fail randomly
          lowerCamelCase__           =		torch.zeros_like(inputs['input_ids']				)
          # make every second token global
          lowerCamelCase__           =		1

          return inputs







"""simple docstring"""


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


_snake_case          =							logging.get_logger(__name__)

_snake_case          =							{
    "microsoft/swinv2-tiny-patch4-window8-256": (
        "https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/resolve/main/config.json"
    ),
}



class   _a      (      SCREAMING_SNAKE_CASE_ ):
    a_    :				Union[str, Any]             =    'swinv2'

    a_    :				Optional[int]             =    {
        'num_attention_heads': 'num_heads',
        'num_hidden_layers': 'num_layers',
    }
    def __init__( self							:					List[str]							,					SCREAMING_SNAKE_CASE__							:					int=2_24							,					SCREAMING_SNAKE_CASE__							:					str=4							,					SCREAMING_SNAKE_CASE__							:					List[Any]=3							,					SCREAMING_SNAKE_CASE__							:					str=96							,					SCREAMING_SNAKE_CASE__							:					Dict=[2, 2, 6, 2]							,					SCREAMING_SNAKE_CASE__							:					Union[str, Any]=[3, 6, 12, 24]							,					SCREAMING_SNAKE_CASE__							:					Tuple=7							,					SCREAMING_SNAKE_CASE__							:					Union[str, Any]=4.0							,					SCREAMING_SNAKE_CASE__							:					List[str]=True							,					SCREAMING_SNAKE_CASE__							:					List[Any]=0.0							,					SCREAMING_SNAKE_CASE__							:					Optional[int]=0.0							,					SCREAMING_SNAKE_CASE__							:					Dict=0.1							,					SCREAMING_SNAKE_CASE__							:					Tuple="gelu"							,					SCREAMING_SNAKE_CASE__							:					Tuple=False							,					SCREAMING_SNAKE_CASE__							:					Any=0.02							,					SCREAMING_SNAKE_CASE__							:					List[Any]=1e-5							,					SCREAMING_SNAKE_CASE__							:					int=32							,					**SCREAMING_SNAKE_CASE__							:					List[str]							,					):
          super().__init__(**SCREAMING_SNAKE_CASE__				)

          lowerCamelCase__           =		image_size
          lowerCamelCase__           =		patch_size
          lowerCamelCase__           =		num_channels
          lowerCamelCase__           =		embed_dim
          lowerCamelCase__           =		depths
          lowerCamelCase__           =		len(SCREAMING_SNAKE_CASE__				)
          lowerCamelCase__           =		num_heads
          lowerCamelCase__           =		window_size
          lowerCamelCase__           =		mlp_ratio
          lowerCamelCase__           =		qkv_bias
          lowerCamelCase__           =		hidden_dropout_prob
          lowerCamelCase__           =		attention_probs_dropout_prob
          lowerCamelCase__           =		drop_path_rate
          lowerCamelCase__           =		hidden_act
          lowerCamelCase__           =		use_absolute_embeddings
          lowerCamelCase__           =		layer_norm_eps
          lowerCamelCase__           =		initializer_range
          lowerCamelCase__           =		encoder_stride
          # we set the hidden_size attribute in order to make Swinv2 work with VisionEncoderDecoderModel
          # this indicates the channel dimension after the last stage of the model
          lowerCamelCase__           =		int(embed_dim * 2 ** (len(SCREAMING_SNAKE_CASE__				) - 1)				)
          lowerCamelCase__           =		(0, 0, 0, 0)



