



"""simple docstring"""




import numpy

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

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						List[Any]						,  SCREAMING_SNAKE_CASE__     :						Optional[Any]="train"    )  ->       Tuple:





     '''simple docstring'''

     return calculate_hypothesis_value(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    ) - output(
         SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Tuple    )  ->       Dict:





     '''simple docstring'''

     _UpperCAmelCase      :     List[Any]        =   0
     for i in range(len(SCREAMING_SNAKE_CASE__    ) - 1    ):
          hyp_val += data_input_tuple[i] * parameter_vector[i + 1]
     hyp_val += parameter_vector[0]
     return hyp_val

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						str						,  SCREAMING_SNAKE_CASE__     :						Optional[Any]    )  ->       str:





     '''simple docstring'''

     if data_set == "train":
          return train_data[example_no][1]
     elif data_set == "test":
          return test_data[example_no][1]
     return None

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Dict						,  SCREAMING_SNAKE_CASE__     :						Any    )  ->       Optional[int]:





     '''simple docstring'''

     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 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Union[str, Any]						,  SCREAMING_SNAKE_CASE__     :						Dict=m    )  ->       str:





     '''simple docstring'''

     _UpperCAmelCase      :     Optional[Any]        =   0
     for i in range(SCREAMING_SNAKE_CASE__    ):
          if index == -1:
               summation_value += _error(SCREAMING_SNAKE_CASE__    )
          else:
               summation_value += _error(SCREAMING_SNAKE_CASE__    ) * train_data[i][0][index]
     return summation_value

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Optional[Any]    )  ->       Tuple:





     '''simple docstring'''

     _UpperCAmelCase      :     Tuple        =   summation_of_cost_derivative(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    ) / m
     return cost_derivative_value

def 						__snake_case						(				)  ->       Optional[Any]:





     '''simple docstring'''

     global parameter_vector
     # Tune these values to set a tolerance value for predicted output
     _UpperCAmelCase      :     List[str]        =   0.000_002
     _UpperCAmelCase      :     Optional[Any]        =   0
     _UpperCAmelCase      :     Union[str, Any]        =   0
     while True:
          j += 1
          _UpperCAmelCase      :     Optional[Any]        =   [0, 0, 0, 0]
          for i in range(0						,  len(SCREAMING_SNAKE_CASE__    )    ):
               _UpperCAmelCase      :     List[str]        =   get_cost_derivative(i - 1    )
               _UpperCAmelCase      :     Optional[int]        =   (
                   parameter_vector[i] - LEARNING_RATE * cost_derivative
               )
          if numpy.allclose(
              SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  atol=SCREAMING_SNAKE_CASE__						,  rtol=SCREAMING_SNAKE_CASE__						,  ):
               break
          _UpperCAmelCase      :     List[Any]        =   temp_parameter_vector
     print(("Number of iterations:", j)    )

def 						__snake_case						(				)  ->       str:





     '''simple docstring'''

     for i in range(len(SCREAMING_SNAKE_CASE__    )    ):
          print(("Actual output value:", output(SCREAMING_SNAKE_CASE__						,  "test"    ))    )
          print(("Hypothesis output:", calculate_hypothesis_value(SCREAMING_SNAKE_CASE__						,  "test"    ))    )


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





"""simple docstring"""




import importlib
import inspect
import os
import re


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_config_docstrings.py
_lowerCAmelCase    : Dict							=							"src/transformers"


# This is to make sure the transformers module imported is the one in the repo.
_lowerCAmelCase    : List[Any]							=							importlib.util.spec_from_file_location(
    "transformers",
    os.path.join(PATH_TO_TRANSFORMERS, "__init__.py"),
    submodule_search_locations=[PATH_TO_TRANSFORMERS],
)
_lowerCAmelCase    : Tuple							=							spec.loader.load_module()

_lowerCAmelCase    : Tuple							=							transformers.models.auto.configuration_auto.CONFIG_MAPPING

# Regex pattern used to find the checkpoint mentioned in the docstring of `config_class`.
# For example, `[bert-base-uncased](https://huggingface.co/bert-base-uncased)`
_lowerCAmelCase    : Optional[int]							=							re.compile("\[(.+?)\]\((https://huggingface\.co/.+?)\)")


_lowerCAmelCase    : Optional[int]							=							{
    "CLIPConfigMixin",
    "DecisionTransformerConfigMixin",
    "EncoderDecoderConfigMixin",
    "RagConfigMixin",
    "SpeechEncoderDecoderConfigMixin",
    "VisionEncoderDecoderConfigMixin",
    "VisionTextDualEncoderConfigMixin",
}

def 						__snake_case						(				)  ->       Dict:





     '''simple docstring'''

     _UpperCAmelCase      :     List[str]        =   []

     for config_class in list(CONFIG_MAPPING.values()    ):
          _UpperCAmelCase      :     Union[str, Any]        =   False

          # source code of `config_class`
          _UpperCAmelCase      :     Optional[int]        =   inspect.getsource(SCREAMING_SNAKE_CASE__    )
          _UpperCAmelCase      :     List[Any]        =   _re_checkpoint.findall(SCREAMING_SNAKE_CASE__    )

          for checkpoint in checkpoints:
               # Each `checkpoint` is a tuple of a checkpoint name and a checkpoint link.
               # For example, `('bert-base-uncased', 'https://huggingface.co/bert-base-uncased')`
               _UpperCAmelCase    ,	_UpperCAmelCase      :     List[Any]        =   checkpoint

               # verify the checkpoint name corresponds to the checkpoint link
               _UpperCAmelCase      :     Optional[Any]        =   f'https://huggingface.co/{ckpt_name}'
               if ckpt_link == ckpt_link_from_name:
                    _UpperCAmelCase      :     Optional[Any]        =   True
                    break

          _UpperCAmelCase      :     int        =   config_class.__name__
          if not checkpoint_found and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
               configs_without_checkpoint.append(SCREAMING_SNAKE_CASE__    )

     if len(SCREAMING_SNAKE_CASE__    ) > 0:
          _UpperCAmelCase      :     List[str]        =   "\n".join(sorted(SCREAMING_SNAKE_CASE__    )    )
          raise ValueError(f'The following configurations don\'t contain any valid checkpoint:\n{message}'    )


if __name__ == "__main__":
 check_config_docstrings_have_checkpoints()
