
"""simple docstring"""






import numpy

# List of input, output pairs
__SCREAMING_SNAKE_CASE							=     (
    ((5, 2, 3), 15),
    ((6, 5, 9), 25),
    ((11, 12, 13), 41),
    ((1, 1, 1), 8),
    ((11, 12, 13), 41),
)
__SCREAMING_SNAKE_CASE							=     (((515, 22, 13), 555), ((61, 35, 49), 150))
__SCREAMING_SNAKE_CASE							=     [2, 4, 1, 5]
__SCREAMING_SNAKE_CASE							=     len(train_data)
__SCREAMING_SNAKE_CASE							=     0.0_09




def       A_  (				__lowercase						,	__lowercase="train"	):
 return calculate_hypothesis_value(__lowercase						,	__lowercase	) - output(
     __lowercase						,	__lowercase	)




def       A_  (				__lowercase	):
 UpperCamelCase_     :					Union[str, Any]   	=0
 for i in range(len(__lowercase	) - 1	):
  hyp_val += data_input_tuple[i] * parameter_vector[i + 1]
 hyp_val += parameter_vector[0]
 return hyp_val




def       A_  (				__lowercase						,	__lowercase	):
 if data_set == "train":
  return train_data[example_no][1]
 elif data_set == "test":
  return test_data[example_no][1]
 return None




def       A_  (				__lowercase						,	__lowercase	):
 if data_set == "train":
  return _hypothesis_value(train_data[example_no][0]	)
 elif data_set == "test":
  return _hypothesis_value(test_data[example_no][0]	)
 return None




def       A_  (				__lowercase						,	__lowercase=m	):
 UpperCamelCase_     :					Any   	=0
 for i in range(__lowercase	):
  if index == -1:
   summation_value += _error(__lowercase	)
  else:
   summation_value += _error(__lowercase	) * train_data[i][0][index]
 return summation_value




def       A_  (				__lowercase	):
 UpperCamelCase_     :					Dict   	=summation_of_cost_derivative(__lowercase						,	__lowercase	) / m
 return cost_derivative_value




def       A_  (				):
 global parameter_vector
 # Tune these values to set a tolerance value for predicted output
 UpperCamelCase_     :					Dict   	=0.000002
 UpperCamelCase_     :					Tuple   	=0
 UpperCamelCase_     :					Optional[Any]   	=0
 while True:
  j += 1
  UpperCamelCase_     :					Tuple   	=[0, 0, 0, 0]
  for i in range(0						,	len(__lowercase	)	):
   UpperCamelCase_     :					Dict   	=get_cost_derivative(i - 1	)
   UpperCamelCase_     :					Dict   	=(
       parameter_vector[i] - LEARNING_RATE * cost_derivative
   )
  if numpy.allclose(
      __lowercase						,	__lowercase						,	atol=__lowercase						,	rtol=__lowercase						,	):
   break
  UpperCamelCase_     :					Optional[Any]   	=temp_parameter_vector
 print(('Number of iterations:', j)	)




def       A_  (				):
 for i in range(len(__lowercase	)	):
  print(('Actual output value:', output(__lowercase						,	'test'	))	)
  print(('Hypothesis output:', calculate_hypothesis_value(__lowercase						,	'test'	))	)


if __name__ == "__main__":
 run_gradient_descent()
 print('\nTesting gradient descent for a linear hypothesis function.\n')
 test_gradient_descent()


"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__SCREAMING_SNAKE_CASE							=     {
    'configuration_whisper': ['WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WhisperConfig', 'WhisperOnnxConfig'],
    'feature_extraction_whisper': ['WhisperFeatureExtractor'],
    'processing_whisper': ['WhisperProcessor'],
    'tokenization_whisper': ['WhisperTokenizer'],
}

try:
 if not is_tokenizers_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __SCREAMING_SNAKE_CASE							=     ['WhisperTokenizerFast']

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __SCREAMING_SNAKE_CASE							=     [
     'WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST',
     'WhisperForConditionalGeneration',
     'WhisperModel',
     'WhisperPreTrainedModel',
     'WhisperForAudioClassification',
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __SCREAMING_SNAKE_CASE							=     [
     'TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST',
     'TFWhisperForConditionalGeneration',
     'TFWhisperModel',
     'TFWhisperPreTrainedModel',
 ]

try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __SCREAMING_SNAKE_CASE							=     [
     'FlaxWhisperForConditionalGeneration',
     'FlaxWhisperModel',
     'FlaxWhisperPreTrainedModel',
     'FlaxWhisperForAudioClassification',
 ]


if TYPE_CHECKING:
 from .configuration_whisper import WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP, WhisperConfig, WhisperOnnxConfig
 from .feature_extraction_whisper import WhisperFeatureExtractor
 from .processing_whisper import WhisperProcessor
 from .tokenization_whisper import WhisperTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_whisper_fast import WhisperTokenizerFast

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_whisper import (
      WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
      WhisperForAudioClassification,
      WhisperForConditionalGeneration,
      WhisperModel,
      WhisperPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_whisper import (
      TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFWhisperForConditionalGeneration,
      TFWhisperModel,
      TFWhisperPreTrainedModel,
  )

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_whisper import (
      FlaxWhisperForAudioClassification,
      FlaxWhisperForConditionalGeneration,
      FlaxWhisperModel,
      FlaxWhisperPreTrainedModel,
  )

else:
 import sys

 __SCREAMING_SNAKE_CASE							=     _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)
