






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

SCREAMING_SNAKE_CASE 							=						logging.get_logger(__name__)

SCREAMING_SNAKE_CASE 							=						{
    "openai/whisper-base": "https://huggingface.co/openai/whisper-base/resolve/main/config.json",
}

# fmt: off
SCREAMING_SNAKE_CASE 							=						[
    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
]
SCREAMING_SNAKE_CASE 							=						[
    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 							A_    (						UpperCamelCase_			):






 '''simple docstring'''




 _SCREAMING_SNAKE_CASE							:			Any =					"""whisper"""
 _SCREAMING_SNAKE_CASE							:			Optional[Any] =					["""past_key_values"""]
 _SCREAMING_SNAKE_CASE							:			Union[str, Any] =					{"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}


 def __init__(	self							,  _A=51865							,  _A=80							,  _A=6							,  _A=4							,  _A=6							,  _A=4							,  _A=1536							,  _A=1536							,  _A=0.0							,  _A=0.0							,  _A=50257							,  _A=True							,  _A=True							,  _A="gelu"							,  _A=256							,  _A=0.0							,  _A=0.0							,  _A=0.0							,  _A=0.02							,  _A=False							,  _A=1500							,  _A=448							,  _A=50256							,  _A=50256							,  _A=50256							,  _A=None							,  _A=[220, 50256]							,  _A=False							,  _A=256							,  _A=False							,  _A=0.05							,  _A=10							,  _A=2							,  _A=0.0							,  _A=10							,  _A=0							,  _A=7							,  **_A							,  ) ->		int:

     """simple docstring"""



     _UpperCAmelCase				:      Optional[Any]			  =				vocab_size
     _UpperCAmelCase				:      List[Any]			  =				num_mel_bins
     _UpperCAmelCase				:      List[Any]			  =				d_model
     _UpperCAmelCase				:      int			  =				encoder_layers
     _UpperCAmelCase				:      Any			  =				encoder_attention_heads
     _UpperCAmelCase				:      Dict			  =				decoder_layers
     _UpperCAmelCase				:      List[Any]			  =				decoder_attention_heads
     _UpperCAmelCase				:      str			  =				decoder_ffn_dim
     _UpperCAmelCase				:      Tuple			  =				encoder_ffn_dim
     _UpperCAmelCase				:      Tuple			  =				dropout
     _UpperCAmelCase				:      int			  =				attention_dropout
     _UpperCAmelCase				:      List[str]			  =				activation_dropout
     _UpperCAmelCase				:      List[Any]			  =				activation_function
     _UpperCAmelCase				:      Optional[Any]			  =				init_std
     _UpperCAmelCase				:      List[Any]			  =				encoder_layerdrop
     _UpperCAmelCase				:      Tuple			  =				decoder_layerdrop
     _UpperCAmelCase				:      List[str]			  =				use_cache
     _UpperCAmelCase				:      Optional[int]			  =				encoder_layers
     _UpperCAmelCase				:      Any			  =				scale_embedding  # scale factor will be sqrt(d_model) if True
     _UpperCAmelCase				:      Any			  =				max_source_positions
     _UpperCAmelCase				:      Optional[int]			  =				max_target_positions

     # Audio Classification-specific parameters. Feel free to ignore for other classes.
     _UpperCAmelCase				:      Optional[int]			  =				classifier_proj_size
     _UpperCAmelCase				:      List[str]			  =				use_weighted_layer_sum

     # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
     _UpperCAmelCase				:      Optional[int]			  =				apply_spec_augment
     _UpperCAmelCase				:      Optional[Any]			  =				mask_time_prob
     _UpperCAmelCase				:      Dict			  =				mask_time_length
     _UpperCAmelCase				:      Any			  =				mask_time_min_masks
     _UpperCAmelCase				:      Any			  =				mask_feature_prob
     _UpperCAmelCase				:      Any			  =				mask_feature_length
     _UpperCAmelCase				:      Dict			  =				mask_feature_min_masks

     _UpperCAmelCase				:      str			  =				median_filter_width

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



class 							A_    (						UpperCamelCase_			):






 '''simple docstring'''




 @property
 def  snake_case__				(	self) ->		Mapping[str, Mapping[int, str]]:

     """simple docstring"""



     _UpperCAmelCase				:      List[Any]			  =				OrderedDict(
         [
             ('''input_features''', {0: '''batch''', 1: '''feature_size''', 2: '''encoder_sequence'''}),
         ])
     if self.use_past:
         _UpperCAmelCase				:      Union[str, Any]			  =				{0: """batch"""}
     else:
         _UpperCAmelCase				:      str			  =				{0: """batch""", 1: """decoder_sequence"""}

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

     return common_inputs


 def  snake_case__				(	self							,  _A							,  _A = -1							,  _A = -1							,  _A = False							,  _A = None							,  _A = 22050							,  _A = 5.0							,  _A = 220							,  ) ->		Mapping[str, Any]:

     """simple docstring"""



     _UpperCAmelCase				:      Optional[int]			  =				OrderedDict()
     _UpperCAmelCase				:      List[Any]			  =				OnnxConfig.generate_dummy_inputs(
         self							,  preprocessor=preprocessor.feature_extractor							,  batch_size=_a							,  framework=_a							,  sampling_rate=_a							,  time_duration=_a							,  frequency=_a							,  )
     _UpperCAmelCase				:      Union[str, Any]			  =				encoder_inputs["""input_features"""].shape[2]
     _UpperCAmelCase				:      Union[str, Any]			  =				encoder_sequence_length // 2 if self.use_past else seq_length

     _UpperCAmelCase				:      Optional[Any]			  =				super().generate_dummy_inputs(
         preprocessor.tokenizer							,  _a							,  _a							,  _a							,  _a)

     _UpperCAmelCase				:      Any			  =				encoder_inputs.pop('''input_features''')
     _UpperCAmelCase				:      Union[str, Any]			  =				decoder_inputs.pop('''decoder_input_ids''')

     if "past_key_values" in decoder_inputs:
         _UpperCAmelCase				:      Optional[Any]			  =				decoder_inputs.pop('''past_key_values''')

     return dummy_inputs


 @property
 def  snake_case__				(	self) ->		float:

     """simple docstring"""



     return 1e-3












# Logistic Regression from scratch

# In[62]:

# In[63]:

# importing all the required libraries

import numpy as np
from matplotlib import pyplot as plt
from sklearn import datasets

def      _lowerCamelCase	(						__A    :							Optional[int] )      ->					str:
    return 1 / (1 + np.exp(-z ))

def      _lowerCamelCase	(						__A    :							Tuple		,		__A    :							List[Any] )      ->					Optional[int]:
    return (-y * np.log(__A ) - (1 - y) * np.log(1 - h )).mean()

def      _lowerCamelCase	(						__A    :							Tuple		,		__A    :							List[Any]		,		__A    :							int )      ->					Any:
    _UpperCAmelCase				:      int			  =				np.dot(__A		,		__A )
    return np.sum(y * scores - np.log(1 + np.exp(__A ) ) )

def      _lowerCamelCase	(						__A    :							List[Any]		,		__A    :							Union[str, Any]		,		__A    :							str		,		__A    :							Dict=70_000 )      ->					Optional[Any]:
    _UpperCAmelCase				:      Union[str, Any]			  =				np.zeros(x.shape[1] )

    for iterations in range(__A ):
        _UpperCAmelCase				:      List[Any]			  =				np.dot(__A		,		__A )
        _UpperCAmelCase				:      Union[str, Any]			  =				sigmoid_function(__A )
        _UpperCAmelCase				:      Optional[Any]			  =				np.dot(x.T		,		h - y ) / y.size
        _UpperCAmelCase				:      Optional[Any]			  =				theta - alpha * gradient  # updating the weights
        _UpperCAmelCase				:      List[Any]			  =				np.dot(__A		,		__A )
        _UpperCAmelCase				:      Any			  =				sigmoid_function(__A )
        _UpperCAmelCase				:      Union[str, Any]			  =				cost_function(__A		,		__A )
        if iterations % 100 == 0:
            print(f'''loss: {j} \t''' )  # printing the loss after every 100 iterations
    return theta


# In[68]:

if __name__ == "__main__":
  SCREAMING_SNAKE_CASE 							=						datasets.load_iris()
  SCREAMING_SNAKE_CASE 							=						iris.data[:, :2]
  SCREAMING_SNAKE_CASE 							=						(iris.target != 0) * 1

  SCREAMING_SNAKE_CASE 							=						0.1
  SCREAMING_SNAKE_CASE 							=						logistic_reg(alpha, x, y, max_iterations=70000)
  print('theta: ', theta)  # printing the theta i.e our weights vector

  def      _lowerCamelCase	(						__A    :							Any )      ->					int:
      return sigmoid_function(
          np.dot(__A		,		__A ) )  # predicting the value of probability from the logistic regression algorithm

  plt.figure(figsize=(10, 6))
  plt.scatter(x[y == 0][:, 0], x[y == 0][:, 1], color='b', label='0')
  plt.scatter(x[y == 1][:, 0], x[y == 1][:, 1], color='r', label='1')
  ((SCREAMING_SNAKE_CASE)							,			(SCREAMING_SNAKE_CASE)) 							=						(x[:, 0].min(), x[:, 0].max())
  ((SCREAMING_SNAKE_CASE)							,			(SCREAMING_SNAKE_CASE)) 							=						(x[:, 1].min(), x[:, 1].max())
  ((SCREAMING_SNAKE_CASE)							,			(SCREAMING_SNAKE_CASE)) 							=						np.meshgrid(np.linspace(xa_min, xa_max), np.linspace(xa_min, xa_max))
  SCREAMING_SNAKE_CASE 							=						np.c_[xxa.ravel(), xxa.ravel()]
  SCREAMING_SNAKE_CASE 							=						predict_prob(grid).reshape(xxa.shape)
  plt.contour(xxa, xxa, probs, [0.5], linewidths=1, colors='black')

  plt.legend()


  plt.show()




