


import numpy

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

def 						_UpperCAmelCase      (      SCREAMING_SNAKE_CASE__      : Tuple      ,					SCREAMING_SNAKE_CASE__      : List[Any]="train"    ):
     return calculate_hypothesis_value(_UpperCamelCase      ,					_UpperCamelCase    ) - output(
         _UpperCamelCase      ,					_UpperCamelCase    )

def 						_UpperCAmelCase      (      SCREAMING_SNAKE_CASE__      : Dict    ):
     __UpperCamelCase   							=0
     for i in range(len(_UpperCamelCase    ) - 1    ):
          hyp_val += data_input_tuple[i] * parameter_vector[i + 1]
     hyp_val += parameter_vector[0]
     return hyp_val

def 						_UpperCAmelCase      (      SCREAMING_SNAKE_CASE__      : Optional[int]      ,					SCREAMING_SNAKE_CASE__      : List[Any]    ):
     if data_set == "train":
          return train_data[example_no][1]
     elif data_set == "test":
          return test_data[example_no][1]
     return None

def 						_UpperCAmelCase      (      SCREAMING_SNAKE_CASE__      : List[str]      ,					SCREAMING_SNAKE_CASE__      : Optional[Any]    ):
     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 						_UpperCAmelCase      (      SCREAMING_SNAKE_CASE__      : Optional[Any]      ,					SCREAMING_SNAKE_CASE__      : Any=m    ):
     __UpperCamelCase   							=0
     for i in range(_UpperCamelCase    ):
          if index == -1:
               summation_value += _error(_UpperCamelCase    )
          else:
               summation_value += _error(_UpperCamelCase    ) * train_data[i][0][index]
     return summation_value

def 						_UpperCAmelCase      (      SCREAMING_SNAKE_CASE__      : Dict    ):
     __UpperCamelCase   							=summation_of_cost_derivative(_UpperCamelCase      ,					_UpperCamelCase    ) / m
     return cost_derivative_value

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

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


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









import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_bert import BertTokenizer


_A			=						logging.get_logger(__name__)

_A			=						{'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'}

_A			=						{
    'vocab_file': {
        'bert-base-uncased': 'https://huggingface.co/bert-base-uncased/resolve/main/vocab.txt',
        'bert-large-uncased': 'https://huggingface.co/bert-large-uncased/resolve/main/vocab.txt',
        'bert-base-cased': 'https://huggingface.co/bert-base-cased/resolve/main/vocab.txt',
        'bert-large-cased': 'https://huggingface.co/bert-large-cased/resolve/main/vocab.txt',
        'bert-base-multilingual-uncased': (
            'https://huggingface.co/bert-base-multilingual-uncased/resolve/main/vocab.txt'
        ),
        'bert-base-multilingual-cased': 'https://huggingface.co/bert-base-multilingual-cased/resolve/main/vocab.txt',
        'bert-base-chinese': 'https://huggingface.co/bert-base-chinese/resolve/main/vocab.txt',
        'bert-base-german-cased': 'https://huggingface.co/bert-base-german-cased/resolve/main/vocab.txt',
        'bert-large-uncased-whole-word-masking': (
            'https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/vocab.txt'
        ),
        'bert-large-cased-whole-word-masking': (
            'https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/vocab.txt'
        ),
        'bert-large-uncased-whole-word-masking-finetuned-squad': (
            'https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/vocab.txt'
        ),
        'bert-large-cased-whole-word-masking-finetuned-squad': (
            'https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/vocab.txt'
        ),
        'bert-base-cased-finetuned-mrpc': (
            'https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/vocab.txt'
        ),
        'bert-base-german-dbmdz-cased': 'https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/vocab.txt',
        'bert-base-german-dbmdz-uncased': (
            'https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/vocab.txt'
        ),
        'TurkuNLP/bert-base-finnish-cased-v1': (
            'https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/vocab.txt'
        ),
        'TurkuNLP/bert-base-finnish-uncased-v1': (
            'https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/vocab.txt'
        ),
        'wietsedv/bert-base-dutch-cased': (
            'https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/vocab.txt'
        ),
    },
    'tokenizer_file': {
        'bert-base-uncased': 'https://huggingface.co/bert-base-uncased/resolve/main/tokenizer.json',
        'bert-large-uncased': 'https://huggingface.co/bert-large-uncased/resolve/main/tokenizer.json',
        'bert-base-cased': 'https://huggingface.co/bert-base-cased/resolve/main/tokenizer.json',
        'bert-large-cased': 'https://huggingface.co/bert-large-cased/resolve/main/tokenizer.json',
        'bert-base-multilingual-uncased': (
            'https://huggingface.co/bert-base-multilingual-uncased/resolve/main/tokenizer.json'
        ),
        'bert-base-multilingual-cased': (
            'https://huggingface.co/bert-base-multilingual-cased/resolve/main/tokenizer.json'
        ),
        'bert-base-chinese': 'https://huggingface.co/bert-base-chinese/resolve/main/tokenizer.json',
        'bert-base-german-cased': 'https://huggingface.co/bert-base-german-cased/resolve/main/tokenizer.json',
        'bert-large-uncased-whole-word-masking': (
            'https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/tokenizer.json'
        ),
        'bert-large-cased-whole-word-masking': (
            'https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/tokenizer.json'
        ),
        'bert-large-uncased-whole-word-masking-finetuned-squad': (
            'https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/tokenizer.json'
        ),
        'bert-large-cased-whole-word-masking-finetuned-squad': (
            'https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/tokenizer.json'
        ),
        'bert-base-cased-finetuned-mrpc': (
            'https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/tokenizer.json'
        ),
        'bert-base-german-dbmdz-cased': (
            'https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/tokenizer.json'
        ),
        'bert-base-german-dbmdz-uncased': (
            'https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/tokenizer.json'
        ),
        'TurkuNLP/bert-base-finnish-cased-v1': (
            'https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/tokenizer.json'
        ),
        'TurkuNLP/bert-base-finnish-uncased-v1': (
            'https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/tokenizer.json'
        ),
        'wietsedv/bert-base-dutch-cased': (
            'https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/tokenizer.json'
        ),
    },
}

_A			=						{
    'bert-base-uncased': 512,
    'bert-large-uncased': 512,
    'bert-base-cased': 512,
    'bert-large-cased': 512,
    'bert-base-multilingual-uncased': 512,
    'bert-base-multilingual-cased': 512,
    'bert-base-chinese': 512,
    'bert-base-german-cased': 512,
    'bert-large-uncased-whole-word-masking': 512,
    'bert-large-cased-whole-word-masking': 512,
    'bert-large-uncased-whole-word-masking-finetuned-squad': 512,
    'bert-large-cased-whole-word-masking-finetuned-squad': 512,
    'bert-base-cased-finetuned-mrpc': 512,
    'bert-base-german-dbmdz-cased': 512,
    'bert-base-german-dbmdz-uncased': 512,
    'TurkuNLP/bert-base-finnish-cased-v1': 512,
    'TurkuNLP/bert-base-finnish-uncased-v1': 512,
    'wietsedv/bert-base-dutch-cased': 512,
}

_A			=						{
    'bert-base-uncased': {'do_lower_case': True},
    'bert-large-uncased': {'do_lower_case': True},
    'bert-base-cased': {'do_lower_case': False},
    'bert-large-cased': {'do_lower_case': False},
    'bert-base-multilingual-uncased': {'do_lower_case': True},
    'bert-base-multilingual-cased': {'do_lower_case': False},
    'bert-base-chinese': {'do_lower_case': False},
    'bert-base-german-cased': {'do_lower_case': False},
    'bert-large-uncased-whole-word-masking': {'do_lower_case': True},
    'bert-large-cased-whole-word-masking': {'do_lower_case': False},
    'bert-large-uncased-whole-word-masking-finetuned-squad': {'do_lower_case': True},
    'bert-large-cased-whole-word-masking-finetuned-squad': {'do_lower_case': False},
    'bert-base-cased-finetuned-mrpc': {'do_lower_case': False},
    'bert-base-german-dbmdz-cased': {'do_lower_case': False},
    'bert-base-german-dbmdz-uncased': {'do_lower_case': True},
    'TurkuNLP/bert-base-finnish-cased-v1': {'do_lower_case': False},
    'TurkuNLP/bert-base-finnish-uncased-v1': {'do_lower_case': True},
    'wietsedv/bert-base-dutch-cased': {'do_lower_case': False},
}






class    UpperCAmelCase__	( A_		):



    """simple docstring"""






    UpperCAmelCase__						:		Any              =  VOCAB_FILES_NAMES
    UpperCAmelCase__						:		List[str]              =  PRETRAINED_VOCAB_FILES_MAP
    UpperCAmelCase__						:		Optional[int]              =  PRETRAINED_INIT_CONFIGURATION
    UpperCAmelCase__						:		List[str]              =  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    UpperCAmelCase__						:		Dict              =  BertTokenizer






    def __init__(      self ,       A_=None ,       A_=None ,       A_=True ,       A_="[UNK]" ,       A_="[SEP]" ,       A_="[PAD]" ,       A_="[CLS]" ,       A_="[MASK]" ,       A_=True ,       A_=None ,       **A_ ,       )  ->	Any:
         super().__init__(
             A_ ,       tokenizer_file=A_ ,       do_lower_case=A_ ,       unk_token=A_ ,       sep_token=A_ ,       pad_token=A_ ,       cls_token=A_ ,       mask_token=A_ ,       tokenize_chinese_chars=A_ ,       strip_accents=A_ ,       **A_ ,       )

         __UpperCamelCase   							=json.loads(self.backend_tokenizer.normalizer.__getstate__()   )
         if (
             normalizer_state.get('lowercase' ,       A_   ) != do_lower_case
             or normalizer_state.get('strip_accents' ,       A_   ) != strip_accents
             or normalizer_state.get('handle_chinese_chars' ,       A_   ) != tokenize_chinese_chars
         ):
              __UpperCamelCase   							=getattr(A_ ,       normalizer_state.pop('type'   )   )
              __UpperCamelCase   							=do_lower_case
              __UpperCamelCase   							=strip_accents
              __UpperCamelCase   							=tokenize_chinese_chars
              __UpperCamelCase   							=normalizer_class(**A_   )

         __UpperCamelCase   							=do_lower_case






    def _a (      self ,       A_ ,       A_=None   )  ->	List[str]:
         __UpperCamelCase   							=[self.cls_token_id] + token_ids_a + [self.sep_token_id]

         if token_ids_a:
              output += token_ids_a + [self.sep_token_id]

         return output






    def _a (      self ,       A_ ,       A_ = None   )  ->	List[int]:
         __UpperCamelCase   							=[self.sep_token_id]
         __UpperCamelCase   							=[self.cls_token_id]
         if token_ids_a is None:
              return len(cls + token_ids_a + sep   ) * [0]
         return len(cls + token_ids_a + sep   ) * [0] + len(token_ids_a + sep   ) * [1]






    def _a (      self ,       A_ ,       A_ = None   )  ->	Tuple[str]:
         __UpperCamelCase   							=self._tokenizer.model.save(A_ ,       name=A_   )
         return tuple(A_   )





