
"""simple docstring"""

import json
import re
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

import numpy as np

from ...utils import is_tf_available, is_torch_available, logging


if TYPE_CHECKING:
   if is_torch_available():
      import torch
   if is_tf_available():
      import tensorflow as tf

from tokenizers import pre_tokenizers

from ...tokenization_utils_base import BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_codegen import CodeGenTokenizer


SCREAMING_SNAKE_CASE_            =    logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_            =    {'''vocab_file''': '''vocab.json''', '''merges_file''': '''merges.txt''', '''tokenizer_file''': '''tokenizer.json'''}

SCREAMING_SNAKE_CASE_            =    {
    '''vocab_file''': {
        '''Salesforce/codegen-350M-mono''': '''https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/vocab.json''',
    },
    '''merges_file''': {
        '''Salesforce/codegen-350M-mono''': '''https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/merges.txt''',
    },
    '''tokenizer_file''': {
        '''Salesforce/codegen-350M-mono''': (
            '''https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/tokenizer.json'''
        ),
    },
}

SCREAMING_SNAKE_CASE_            =    {
    '''Salesforce/codegen-350M-mono''': 2048,
}
class   _UpperCAmelCase				(		SCREAMING_SNAKE_CASE_				):
      __SCREAMING_SNAKE_CASE :				List[str]				   =						VOCAB_FILES_NAMES
      __SCREAMING_SNAKE_CASE :				Tuple				   =						PRETRAINED_VOCAB_FILES_MAP
      __SCREAMING_SNAKE_CASE :				Union[str, Any]				   =						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
      __SCREAMING_SNAKE_CASE :				Optional[Any]				   =						["input_ids", "attention_mask"]
      __SCREAMING_SNAKE_CASE :				Any				   =						CodeGenTokenizer




      def __init__(				self ,							lowercase_=None ,							lowercase_=None ,							lowercase_=None ,							lowercase_="<|endoftext|>" ,							lowercase_="<|endoftext|>" ,							lowercase_="<|endoftext|>" ,							lowercase_=False ,							**lowercase_ ,							)    ->       Tuple:
          super().__init__(
              lowercase_ ,							lowercase_ ,							tokenizer_file=lowercase_ ,							unk_token=lowercase_ ,							bos_token=lowercase_ ,							eos_token=lowercase_ ,							add_prefix_space=lowercase_ ,							**lowercase_ ,							)

          if kwargs.pop('add_bos_token' ,							lowercase_				):
              UpperCAmelCase          =       kwargs.pop('name_or_path' ,							''				)
              raise ValueError(
                  'Currenty GPT2\'s fast tokenizer does NOT support adding a BOS token.'
                  'Instead you should use GPT2\'s slow tokenizer class `CodeGenTokenizer` as follows: \n'
                  F"`CodeGenTokenizer.from_pretrained('{model_id}')`\nor\n"
                  F"`AutoTokenizer.from_pretrained('{model_id}', use_fast=False)`\n"
                  'This issue will be fixed soon, see: https://github.com/huggingface/tokenizers/pull/1005.'
                  ' so that the fast tokenizer works correctly.'				)

          UpperCAmelCase          =       json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()				)
          if pre_tok_state.get('add_prefix_space' ,							lowercase_				) != add_prefix_space:
              UpperCAmelCase          =       getattr(lowercase_ ,							pre_tok_state.pop('type'				)				)
              UpperCAmelCase          =       add_prefix_space
              UpperCAmelCase          =       pre_tok_class(**lowercase_				)

          UpperCAmelCase          =       add_prefix_space




      def      a_   (				self ,							*lowercase_ ,							**lowercase_				)    ->       BatchEncoding:
          UpperCAmelCase          =       kwargs.get('is_split_into_words' ,							lowercase_				)
          assert self.add_prefix_space or not is_split_into_words, (
              F"You need to instantiate {self.__class__.__name__} with add_prefix_space=True "
              "to use it with pretokenized inputs."
          )

          return super()._batch_encode_plus(*lowercase_ ,							**lowercase_				)




      def      a_   (				self ,							*lowercase_ ,							**lowercase_				)    ->       BatchEncoding:
          UpperCAmelCase          =       kwargs.get('is_split_into_words' ,							lowercase_				)

          assert self.add_prefix_space or not is_split_into_words, (
              F"You need to instantiate {self.__class__.__name__} with add_prefix_space=True "
              "to use it with pretokenized inputs."
          )

          return super()._encode_plus(*lowercase_ ,							**lowercase_				)




      def      a_   (				self ,							lowercase_ ,							lowercase_ = None				)    ->       Tuple[str]:
          UpperCAmelCase          =       self._tokenizer.model.save(lowercase_ ,							name=lowercase_				)
          return tuple(lowercase_				)




      def      a_   (				self ,							lowercase_ ,							lowercase_ = False ,							lowercase_ = None ,							lowercase_ = None ,							**lowercase_ ,							)    ->       str:
          UpperCAmelCase          =       super().decode(
              token_ids=lowercase_ ,							skip_special_tokens=lowercase_ ,							clean_up_tokenization_spaces=lowercase_ ,							**lowercase_ ,							)

          if truncate_before_pattern is not None and len(lowercase_				) > 0:
              UpperCAmelCase          =       self.truncate(lowercase_ ,							lowercase_				)

          return decoded_text




      def      a_   (				self ,							lowercase_ ,							lowercase_				)    ->       Union[str, Any]:
          def find_re(lowercase_ ,							lowercase_ ,							lowercase_				):
              UpperCAmelCase          =       pattern.search(lowercase_ ,							lowercase_				)
              return m.start() if m else -1

          UpperCAmelCase          =       [re.compile(lowercase_ ,							re.MULTILINE				) for pattern in truncate_before_pattern]

          UpperCAmelCase          =       list(re.finditer('^print' ,							lowercase_ ,							re.MULTILINE				)				)

          if len(lowercase_				) > 1:
              UpperCAmelCase          =       completion[: prints[1].start()]

          UpperCAmelCase          =       list(re.finditer('^def' ,							lowercase_ ,							re.MULTILINE				)				)

          if len(lowercase_				) > 1:
              UpperCAmelCase          =       completion[: defs[1].start()]

          UpperCAmelCase          =       0

          UpperCAmelCase          =       [
              pos for pos in [find_re(lowercase_ ,							lowercase_ ,							lowercase_				) for terminal in terminals] if pos != -1
          ]

          if len(lowercase_				) > 0:
              return completion[: min(lowercase_				)]
          else:
              return completion





"""simple docstring"""

from math import asin, atan, cos, radians, sin, sqrt, tan

SCREAMING_SNAKE_CASE_            =    6_3_7_8_1_3_7.0
SCREAMING_SNAKE_CASE_            =    6_3_5_6_7_5_2.3_1_4_2_4_5
SCREAMING_SNAKE_CASE_            =    637_8137




def      lowercase__    (       lowerCAmelCase					:       float			,					lowerCAmelCase					:       float			,					lowerCAmelCase					:       float			,					lowerCAmelCase					:       float			)			->   float:






    """simple docstring"""




    UpperCAmelCase          =       (AXIS_A - AXIS_B) / AXIS_A
    UpperCAmelCase          =       atan((1 - flattening) * tan(radians(lowerCAmelCase			)			)			)
    UpperCAmelCase          =       atan((1 - flattening) * tan(radians(lowerCAmelCase			)			)			)
    UpperCAmelCase          =       radians(lowerCAmelCase			)
    UpperCAmelCase          =       radians(lowerCAmelCase			)
    # Equation
    UpperCAmelCase          =       sin((phi_a - phi_a) / 2			)
    UpperCAmelCase          =       sin((lambda_a - lambda_a) / 2			)
    # Square both values
    sin_sq_phi *= sin_sq_phi
    sin_sq_lambda *= sin_sq_lambda
    UpperCAmelCase          =       sqrt(sin_sq_phi + (cos(lowerCAmelCase			) * cos(lowerCAmelCase			) * sin_sq_lambda)			)
    return 2 * RADIUS * asin(lowerCAmelCase			)


if __name__ == "__main__":
   import doctest

   doctest.testmod()



