



import numpy

# List of input, output pairs
a__   :					Dict 						=      (
    ((5, 2, 3), 15),
    ((6, 5, 9), 25),
    ((11, 12, 13), 41),
    ((1, 1, 1), 8),
    ((11, 12, 13), 41),
)
a__   :					str 						=      (((5_15, 22, 13), 5_55), ((61, 35, 49), 1_50))
a__   :					str 						=      [2, 4, 1, 5]
a__   :					Optional[Any] 						=      len(train_data)
a__   :					List[Any] 						=      0.0_0_9

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

def 	_lowerCAmelCase (    A__						):
      lowercase__  =	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 	_lowerCAmelCase (    A__    ,	A__						):
      if data_set == "train":
            return train_data[example_no][1]
      elif data_set == "test":
            return test_data[example_no][1]
      return None

def 	_lowerCAmelCase (    A__    ,	A__						):
      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 	_lowerCAmelCase (    A__    ,	A__=m						):
      lowercase__  =	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 	_lowerCAmelCase (    A__						):
      lowercase__  =	summation_of_cost_derivative(__lowercase    ,	__lowercase						) / m
      return cost_derivative_value

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

def 	_lowerCAmelCase (    ):
      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__)
