"""simple docstring"""



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


SCREAMING_SNAKE_CASE__:List[Any]			=	logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__:int			=	{
    """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 				snake_case__     (   snake_case_   ):
 _snake_case   :			Optional[Any]           =		"""longformer"""


 def __init__(				self  ,						lowerCamelCase = 512  ,						lowerCamelCase = 2  ,						lowerCamelCase = 1  ,						lowerCamelCase = 0  ,						lowerCamelCase = 2  ,						lowerCamelCase = 30522  ,						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 = False  ,						**lowerCamelCase  ,						):
        super().__init__(pad_token_id=lowerCamelCase  ,						**lowerCamelCase		)

        __a     				=  attention_window
        __a     				=  sep_token_id
        __a     				=  bos_token_id
        __a     				=  eos_token_id
        __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     				=  onnx_export






class 				snake_case__     (   snake_case_   ):


 def __init__(				self  ,						lowerCamelCase  ,						lowerCamelCase = "default"  ,						lowerCamelCase = None		):
        super().__init__(lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase		)
        __a     				=  True


 @property
 def 		a__ (				self		):
        if self.task == "multiple-choice":
               __a     				=  {0: "batch", 1: "choice", 2: "sequence"}
        else:
               __a     				=  {0: "batch", 1: "sequence"}
        return OrderedDict(
            [
                ("input_ids", dynamic_axis),
                ("attention_mask", dynamic_axis),
                ("global_attention_mask", dynamic_axis),
            ]		)


 @property
 def 		a__ (				self		):
        __a     				=  super().outputs
        if self.task == "default":
               __a     				=  {0: "batch"}
        return outputs


 @property
 def 		a__ (				self		):
        return 1E-4


 @property
 def 		a__ (				self		):
        # needs to be >= 14 to support tril operator
        return max(super().default_onnx_opset  ,						14		)






 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase = -1  ,						lowerCamelCase = -1  ,						lowerCamelCase = False  ,						lowerCamelCase = None  ,						):
        __a     				=  super().generate_dummy_inputs(
            preprocessor=lowerCamelCase  ,						batch_size=lowerCamelCase  ,						seq_length=lowerCamelCase  ,						is_pair=lowerCamelCase  ,						framework=lowerCamelCase		)
        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
        __a     				=  torch.zeros_like(inputs["input_ids"]		)
        # make every second token global
        __a     				=  1

        return inputs

"""simple docstring"""



from ...processing_utils import ProcessorMixin






class 				snake_case__     (   snake_case_   ):
 _snake_case   :			List[str]           =		"""WhisperFeatureExtractor"""
 _snake_case   :			Any           =		"""WhisperTokenizer"""


 def __init__(				self  ,						lowerCamelCase  ,						lowerCamelCase		):
        super().__init__(lowerCamelCase  ,						lowerCamelCase		)
        __a     				=  self.feature_extractor
        __a     				=  False


 def 		a__ (				self  ,						lowerCamelCase=None  ,						lowerCamelCase=None  ,						lowerCamelCase=True		):
        return self.tokenizer.get_decoder_prompt_ids(task=lowerCamelCase  ,						language=lowerCamelCase  ,						no_timestamps=lowerCamelCase		)


 def __call__(				self  ,						*lowerCamelCase  ,						**lowerCamelCase		):
        # For backward compatibility
        if self._in_target_context_manager:
               return self.current_processor(*lowerCamelCase  ,						**lowerCamelCase		)

        __a     				=  kwargs.pop("audio"  ,						lowerCamelCase		)
        __a     				=  kwargs.pop("sampling_rate"  ,						lowerCamelCase		)
        __a     				=  kwargs.pop("text"  ,						lowerCamelCase		)
        if len(lowerCamelCase		) > 0:
               __a     				=  args[0]
               __a     				=  args[1:]

        if audio is None and text is None:
               raise ValueError("You need to specify either an `audio` or `text` input to process."		)

        if audio is not None:
               __a     				=  self.feature_extractor(lowerCamelCase  ,						*lowerCamelCase  ,						sampling_rate=lowerCamelCase  ,						**lowerCamelCase		)
        if text is not None:
               __a     				=  self.tokenizer(lowerCamelCase  ,						**lowerCamelCase		)

        if text is None:
               return inputs

        elif audio is None:
               return encodings
        else:
               __a     				=  encodings["input_ids"]
               return inputs


 def 		a__ (				self  ,						*lowerCamelCase  ,						**lowerCamelCase		):
        return self.tokenizer.batch_decode(*lowerCamelCase  ,						**lowerCamelCase		)


 def 		a__ (				self  ,						*lowerCamelCase  ,						**lowerCamelCase		):
        return self.tokenizer.decode(*lowerCamelCase  ,						**lowerCamelCase		)






 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase="np"		):
        return self.tokenizer.get_prompt_ids(lowerCamelCase  ,						return_tensors=lowerCamelCase		)
