


'''simple docstring'''







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

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


if TYPE_CHECKING:
   from ...feature_extraction_utils import FeatureExtractionMixin
   from ...tokenization_utils_base import PreTrainedTokenizerBase
   from ...utils import TensorType

A				:					List[str]    						=			logging.get_logger(__name__)

A				:					str    						=			{
    '''openai/whisper-base''': '''https://huggingface.co/openai/whisper-base/resolve/main/config.json''',
}

# fmt: off
A				:					List[Any]    						=			[
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 357, 366, 438, 532, 685,
    705, 796, 930, 1058, 1220, 1267, 1279, 1303, 1343, 1377,
    1391, 1635, 1782, 1875, 2162, 2361, 2488, 3467, 4008, 4211,
    4600, 4808, 5299, 5855, 6329, 7203, 9609, 9959, 10563, 10786,
    11420, 11709, 11907, 13163, 13697, 13700, 14808, 15306, 16410, 16791,
    17992, 19203, 19510, 20724, 22305, 22935, 27007, 30109, 30420, 33409,
    34949, 40283, 40493, 40549, 47282, 49146, 50257, 50359, 50360, 50361
]
A				:					Optional[int]    						=			[
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 359, 503, 522, 542, 873,
    893, 902, 918, 922, 931, 1350, 1853, 1982, 2460, 2627,
    3246, 3253, 3268, 3536, 3846, 3961, 4183, 4667, 6585, 6647,
    7273, 9061, 9383, 10428, 10929, 11938, 12033, 12331, 12562, 13793,
    14157, 14635, 15265, 15618, 16553, 16604, 18362, 18956, 20075, 21675,
    22520, 26130, 26161, 26435, 28279, 29464, 31650, 32302, 32470, 36865,
    42863, 47425, 49870, 50254, 50258, 50360, 50361, 50362
]


class 			__lowerCamelCase			(	a_	):
    """simple docstring"""
    a													=   "whisper"
    a													=   ["past_key_values"]
    a													=   {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}


    def __init__(  self      :							int				,							SCREAMING_SNAKE_CASE      :							int=51865				,							SCREAMING_SNAKE_CASE      :							str=80				,							SCREAMING_SNAKE_CASE      :							int=6				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=4				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=6				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=4				,							SCREAMING_SNAKE_CASE      :							List[str]=1536				,							SCREAMING_SNAKE_CASE      :							Dict=1536				,							SCREAMING_SNAKE_CASE      :							Dict=0.0				,							SCREAMING_SNAKE_CASE      :							Optional[Any]=0.0				,							SCREAMING_SNAKE_CASE      :							int=50257				,							SCREAMING_SNAKE_CASE      :							Any=True				,							SCREAMING_SNAKE_CASE      :							Optional[int]=True				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]="gelu"				,							SCREAMING_SNAKE_CASE      :							Any=256				,							SCREAMING_SNAKE_CASE      :							Optional[int]=0.0				,							SCREAMING_SNAKE_CASE      :							str=0.0				,							SCREAMING_SNAKE_CASE      :							Tuple=0.0				,							SCREAMING_SNAKE_CASE      :							List[str]=0.02				,							SCREAMING_SNAKE_CASE      :							Optional[Any]=False				,							SCREAMING_SNAKE_CASE      :							List[str]=1500				,							SCREAMING_SNAKE_CASE      :							Dict=448				,							SCREAMING_SNAKE_CASE      :							Optional[Any]=50256				,							SCREAMING_SNAKE_CASE      :							Dict=50256				,							SCREAMING_SNAKE_CASE      :							str=50256				,							SCREAMING_SNAKE_CASE      :							Any=None				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=[220, 50256]				,							SCREAMING_SNAKE_CASE      :							Optional[Any]=False				,							SCREAMING_SNAKE_CASE      :							Optional[Any]=256				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=False				,							SCREAMING_SNAKE_CASE      :							Tuple=0.05				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=10				,							SCREAMING_SNAKE_CASE      :							List[Any]=2				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=0.0				,							SCREAMING_SNAKE_CASE      :							Any=10				,							SCREAMING_SNAKE_CASE      :							Any=0				,							SCREAMING_SNAKE_CASE      :							List[str]=7				,							**SCREAMING_SNAKE_CASE      :							Any				,							):
           _A					:     int     = vocab_size
           _A					:     Any     = num_mel_bins
           _A					:     int     = d_model
           _A					:     Optional[Any]     = encoder_layers
           _A					:     Tuple     = encoder_attention_heads
           _A					:     Optional[Any]     = decoder_layers
           _A					:     str     = decoder_attention_heads
           _A					:     Optional[Any]     = decoder_ffn_dim
           _A					:     Optional[int]     = encoder_ffn_dim
           _A					:     List[str]     = dropout
           _A					:     List[str]     = attention_dropout
           _A					:     Tuple     = activation_dropout
           _A					:     Dict     = activation_function
           _A					:     Optional[Any]     = init_std
           _A					:     int     = encoder_layerdrop
           _A					:     str     = decoder_layerdrop
           _A					:     Tuple     = use_cache
           _A					:     int     = encoder_layers
           _A					:     Union[str, Any]     = scale_embedding  # scale factor will be sqrt(d_model) if True
           _A					:     int     = max_source_positions
           _A					:     List[Any]     = max_target_positions

           # Audio Classification-specific parameters. Feel free to ignore for other classes.
           _A					:     Tuple     = classifier_proj_size
           _A					:     int     = use_weighted_layer_sum

           # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
           _A					:     Dict     = apply_spec_augment
           _A					:     str     = mask_time_prob
           _A					:     Tuple     = mask_time_length
           _A					:     Dict     = mask_time_min_masks
           _A					:     Union[str, Any]     = mask_feature_prob
           _A					:     Dict     = mask_feature_length
           _A					:     Dict     = mask_feature_min_masks

           _A					:     int     = median_filter_width

           super().__init__(
               pad_token_id=SCREAMING_SNAKE_CASE				,							bos_token_id=SCREAMING_SNAKE_CASE				,							eos_token_id=SCREAMING_SNAKE_CASE				,							is_encoder_decoder=SCREAMING_SNAKE_CASE				,							decoder_start_token_id=SCREAMING_SNAKE_CASE				,							suppress_tokens=SCREAMING_SNAKE_CASE				,							begin_suppress_tokens=SCREAMING_SNAKE_CASE				,							**SCREAMING_SNAKE_CASE				,							)




class 			__lowerCamelCase			(	a_	):
    """simple docstring"""


    @property
    def        A   (  self      :							Tuple):
           _A					:     Optional[Any]     = OrderedDict(
               [
                   ('input_features', {0: 'batch', 1: 'feature_size', 2: 'encoder_sequence'}),
               ])
           if self.use_past:
                  _A					:     Optional[Any]     = {0: 'batch'}
           else:
                  _A					:     str     = {0: 'batch', 1: 'decoder_sequence'}

           if self.use_past:
                  self.fill_with_past_key_values_(SCREAMING_SNAKE_CASE				,							direction='inputs')

           return common_inputs


    def        A   (  self      :							str				,							SCREAMING_SNAKE_CASE      :							Union["PreTrainedTokenizerBase", "FeatureExtractionMixin"]				,							SCREAMING_SNAKE_CASE      :							int = -1				,							SCREAMING_SNAKE_CASE      :							int = -1				,							SCREAMING_SNAKE_CASE      :							bool = False				,							SCREAMING_SNAKE_CASE      :							Optional["TensorType"] = None				,							SCREAMING_SNAKE_CASE      :							int = 22050				,							SCREAMING_SNAKE_CASE      :							float = 5.0				,							SCREAMING_SNAKE_CASE      :							int = 220				,							):
           _A					:     Tuple     = OrderedDict()
           _A					:     str     = OnnxConfig.generate_dummy_inputs(
               self				,							preprocessor=preprocessor.feature_extractor				,							batch_size=SCREAMING_SNAKE_CASE				,							framework=SCREAMING_SNAKE_CASE				,							sampling_rate=SCREAMING_SNAKE_CASE				,							time_duration=SCREAMING_SNAKE_CASE				,							frequency=SCREAMING_SNAKE_CASE				,							)
           _A					:     Optional[int]     = encoder_inputs['input_features'].shape[2]
           _A					:     List[str]     = encoder_sequence_length // 2 if self.use_past else seq_length

           _A					:     str     = super().generate_dummy_inputs(
               preprocessor.tokenizer				,							SCREAMING_SNAKE_CASE				,							SCREAMING_SNAKE_CASE				,							SCREAMING_SNAKE_CASE				,							SCREAMING_SNAKE_CASE)

           _A					:     Any     = encoder_inputs.pop('input_features')
           _A					:     Any     = decoder_inputs.pop('decoder_input_ids')

           if "past_key_values" in decoder_inputs:
                  _A					:     Tuple     = decoder_inputs.pop('past_key_values')

           return dummy_inputs


    @property
    def        A   (  self      :							Union[str, Any]):
           return 1e-3










'''simple docstring'''







from dataclasses import dataclass, field
from typing import Optional


@dataclass
class 			__lowerCamelCase			:
    """simple docstring"""
    a													=   field(
        default="codeparrot/codeparrot"    , metadata={"help": "Model name or path of model to be trained."}	)
    a													=   field(
        default="./"    , metadata={"help": "Save dir where model repo is cloned and models updates are saved to."}	)
    a													=   field(
        default="codeparrot/codeparrot-clean-train"    , metadata={"help": "Name or path of training dataset."}	)
    a													=   field(
        default="codeparrot/codeparrot-clean-valid"    , metadata={"help": "Name or path of validation dataset."}	)
    a													=   field(default=2    , metadata={"help": "Batch size for training."}	)
    a													=   field(default=2    , metadata={"help": "Batch size for evaluation."}	)
    a													=   field(default=0.1    , metadata={"help": "Value of weight decay."}	)
    a													=   field(
        default=1_0000    , metadata={"help": "Size of buffer used to shuffle streaming dataset."}	)
    a													=   field(default=2E-4    , metadata={"help": "Learning rate fo training."}	)
    a													=   field(default="cosine"    , metadata={"help": "Learning rate."}	)
    a													=   field(
        default=750    , metadata={"help": "Number of warmup steps in the learning rate schedule."}	)
    a													=   field(
        default=16    , metadata={"help": "Number of gradient accumulation steps."}	)
    a													=   field(
        default=a_    , metadata={"help": "Use gradient checkpointing to reduce memory footprint."}	)
    a													=   field(default=5_0000    , metadata={"help": "Maximum number of training steps."}	)
    a													=   field(
        default=-1    , metadata={"help": "Maximum number of evaluation steps. If -1 the full dataset is evaluated."}	)
    a													=   field(default=1024    , metadata={"help": "Sequence lengths used for training."}	)
    a													=   field(default=1    , metadata={"help": "Training seed."}	)
    a													=   field(
        default=1024    , metadata={"help": "Interval to save checkpoints. Measured as number of forward passes not training steps."}    , )
    a													=   field(
        default=a_    , metadata={"help": "States path if the training should continue from a checkpoint folder."}	)
    a													=   field(default=a_    , metadata={"help": "If True the data is pretokenized."}	)




@dataclass
class 			__lowerCamelCase			:
    """simple docstring"""
    a													=   field(
        default="codeparrot/codeparrot"    , metadata={"help": "Model name or path of model to be evaluated."}	)
    a													=   field(
        default="codeparrot/codeparrot-clean-valid"    , metadata={"help": "Name or path of validation dataset."}	)
    a													=   field(default=2    , metadata={"help": "Batch size used for evaluation."}	)
    a													=   field(
        default=-1    , metadata={"help": "Maximum number of evaluation steps. If -1 the full dataset is evaluated."}	)
    a													=   field(default=1024    , metadata={"help": "Length of sequences to be evaluated."}	)
    a													=   field(default=1    , metadata={"help": "Random seed used for evaluation."}	)




@dataclass
class 			__lowerCamelCase			:
    """simple docstring"""
    a													=   field(
        default="codeparrot/codeparrot"    , metadata={"help": "Model name or path of model to be evaluated."}	)
    a													=   field(default=a_    , metadata={"help": "Number of workers used for code evaluation."}	)
    a													=   field(
        default=a_    , metadata={"help": "The number of human-eval tasks to run. If not included all tasks are evaluated."}    , )
    a													=   field(
        default=a_    , metadata={"help": "Sample from the language model's output distribution."}	)
    a													=   field(default=0.2    , metadata={"help": "Sampling temperature used for generation."}	)
    a													=   field(default=256    , metadata={"help": "Maximum number of newly generated tokens."}	)
    a													=   field(default=0    , metadata={"help": "Top-k parameter used for generation."}	)
    a													=   field(default=0.95    , metadata={"help": "Top-p parameter used for nucleus sampling."}	)
    a													=   field(default=10    , metadata={"help": "Number of generations to run in parallel."}	)
    a													=   field(
        default=200    , metadata={"help": "Number of completions to generate for each sample."}	)
    a													=   field(default=1    , metadata={"help": "Random seed used for evaluation."}	)
    a													=   field(
        default="eval_results.json"    , metadata={"help": "Random seed used for evaluation."}	)
    a													=   field(
        default="0"    , metadata={"help": "Allow `code_eval` to execute Python code on machine"}	)
    a													=   field(
        default=-1    , metadata={
            "help": (
                "Determine which device to run the `text-generation` Pipeline on. -1 is CPU and any zero or positive"
                " number corresponds to which GPU device id to run on."
            )
        }    , )




@dataclass
class 			__lowerCamelCase			:
    """simple docstring"""
    a													=   field(
        default=a_    , metadata={
            "help": "The number of CPU cores to use for parallel preprocessing. Default uses the maximum available."
        }    , )
    a													=   field(
        default="transformersbook/codeparrot"    , metadata={"help": "Folder or name of dataset to process."}	)
    a													=   field(
        default="codeparrot-clean"    , metadata={"help": "Folder to save processed processed dataset."}	)
    a													=   field(
        default=10_0000    , metadata={"help": "Number of files to save per JSON output file."}	)
    a													=   field(default="content"    , metadata={"help": "Column containing text data to process."}	)
    a													=   field(
        default=1000    , metadata={"help": "Maximum line length in file, otherwise file is filtered."}	)
    a													=   field(
        default=100    , metadata={"help": "Maximum mean line length in file, otherwise file is filtered."}	)
    a													=   field(
        default=0.25    , metadata={"help": "Maximum fraction of non-alphanumeric characters, otherwise file is filtered."}	)
    a													=   field(
        default=1.5    , metadata={"help": "Minimum character token ratio for the file, otherwise file is filtered."}	)
    a													=   field(
        default=0.7    , metadata={"help": "Probability for filtering config, test and uncommon files."}	)
    a													=   field(
        default="codeparrot/codeparrot"    , metadata={"help": "Name or path to the tokenizer."}    , )
    a													=   field(
        default=a_    , metadata={"help": "If True, near-duplicate samples are removed."}	)
    a													=   field(
        default=0.85    , metadata={"help": "Jaccard threshold for near-duplicate samples."}	)




@dataclass
class 			__lowerCamelCase			:
    """simple docstring"""
    a													=   field(
        default="gpt2"    , metadata={"help": "Base tokenizer to build new tokenizer from."}	)
    a													=   field(
        default="transformersbook/codeparrot-train"    , metadata={"help": "Dataset to train tokenizer on."}	)
    a													=   field(default="content"    , metadata={"help": "Column containing text data to process."}	)
    a													=   field(default=20_0000    , metadata={"help": "Number of examples to train tokenizer on."}	)
    a													=   field(
        default=3_2768    , metadata={"help": "Number of examples to train the tokenizer on."}	)
    a													=   field(default="codeparrot"    , metadata={"help": "Name of new tokenizer."}	)
    a													=   field(default=a_    , metadata={"help": "Push saved tokenizer to the hub."}	)




@dataclass
class 			__lowerCamelCase			:
    """simple docstring"""
    a													=   field(
        default="codeparrot/codeparrot"    , metadata={"help": "Name or path to the tokenizer."}	)
    a													=   field(
        default="codeparrot/codeparrot-clean-train"    , metadata={"help": "Name or path to the dataset to pretokenize."}	)
    a													=   field(
        default="tokenized-codeparrot-train"    , metadata={"help": "Repo name of the pretokenized data."}	)
    a													=   field(default=a_    , metadata={"help": "Number of workers used for code evaluation."}	)




@dataclass
class 			__lowerCamelCase			:
    """simple docstring"""
    a													=   field(
        default="gpt2-large"    , metadata={"help": "Configuration to use for model initialization."}	)
    a													=   field(
        default="codeparrot/codeparrot"    , metadata={"help": "Tokenizer attached to model."}	)
    a													=   field(default="codeparrot"    , metadata={"help": "Name of the created model."}	)
    a													=   field(default=a_    , metadata={"help": "Push saved tokenizer to the hub."}	)






