





'''simple docstring'''

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

from .haversine_distance import haversine_distance

UpperCAmelCase					:		str  =							6_3_7_8_1_3_7.0
UpperCAmelCase					:		List[Any]  =							6_3_5_6_7_5_2.3_1_4_2_4_5
UpperCAmelCase					:		Union[str, Any]  =							6_3_7_8_1_3_7




def    _a    (							lowerCAmelCase_			,      lowerCAmelCase_			,      lowerCAmelCase_			,      lowerCAmelCase_	):





      """simple docstring"""



      _snake_case		:	Dict					     =     (AXIS_A - AXIS_B) / AXIS_A
      # Parametric latitudes
      # https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude
      _snake_case		:	Optional[Any]					     =     atan((1 - flattening) * tan(radians(lowerCAmelCase_	)	)	)
      _snake_case		:	Tuple					     =     atan((1 - flattening) * tan(radians(lowerCAmelCase_	)	)	)

      # Compute central angle between two points
      # using haversine theta. sigma =  haversine_distance / equatorial radius
      _snake_case		:	List[str]					     =     haversine_distance(lowerCAmelCase_			,      lowerCAmelCase_			,      lowerCAmelCase_			,      lowerCAmelCase_	) / EQUATORIAL_RADIUS

      # Intermediate P and Q values
      _snake_case		:	int					     =     (b_lata + b_lata) / 2
      _snake_case		:	Optional[int]					     =     (b_lata - b_lata) / 2

      # Intermediate X value
      # X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2)
      _snake_case		:	Dict					     =     (sin(lowerCAmelCase_	) ** 2) * (cos(lowerCAmelCase_	) ** 2)
      _snake_case		:	Optional[Any]					     =     cos(sigma / 2	) ** 2
      _snake_case		:	Optional[Any]					     =     (sigma - sin(lowerCAmelCase_	)) * (x_numerator / x_demonimator)

      # Intermediate Y value
      # Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2)
      _snake_case		:	Optional[Any]					     =     (cos(lowerCAmelCase_	) ** 2) * (sin(lowerCAmelCase_	) ** 2)
      _snake_case		:	List[str]					     =     sin(sigma / 2	) ** 2
      _snake_case		:	Optional[Any]					     =     (sigma + sin(lowerCAmelCase_	)) * (y_numerator / y_denominator)

      return EQUATORIAL_RADIUS * (sigma - ((flattening / 2) * (x_value + y_value)))


if __name__ == "__main__":
   import doctest

   doctest.testmod()









'''simple docstring'''

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

from tokenizers import pre_tokenizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging


if TYPE_CHECKING:
   from transformers.pipelines.conversational import Conversation


UpperCAmelCase					:		Optional[int]		=							logging.get_logger(__name__)

UpperCAmelCase					:		List[Any]		=							{'vocab_file': 'vocab.json', 'merges_file': 'merges.txt', 'tokenizer_file': 'tokenizer.json'}

UpperCAmelCase					:		Any		=							{
    'tokenizer_file': {
        'EleutherAI/gpt-neox-20b': 'https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/tokenizer.json',
    },
}

UpperCAmelCase					:		Optional[Any]		=							{
    'gpt-neox-20b': 2_0_4_8,
}





class lowerCamelCase						(a__					):
  _lowercase  :	Optional[int]       					=				VOCAB_FILES_NAMES
  _lowercase  :	str       					=				PRETRAINED_VOCAB_FILES_MAP
  _lowercase  :	Dict       					=				PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
  _lowercase  :	Optional[int]       					=				["""input_ids""", """attention_mask"""]







  def __init__(		self     ,     lowercase__=None     ,     lowercase__=None     ,     lowercase__=None     ,     lowercase__="<|endoftext|>"     ,     lowercase__="<|endoftext|>"     ,     lowercase__="<|endoftext|>"     ,     lowercase__=False     ,     **lowercase__     ,     )		->						List[Any]:






        """simple docstring"""





        super().__init__(
            lowercase__     ,     lowercase__     ,     tokenizer_file=lowercase__     ,     unk_token=lowercase__     ,     bos_token=lowercase__     ,     eos_token=lowercase__     ,     add_prefix_space=lowercase__     ,     **lowercase__     ,     )

        _snake_case		:	Optional[int]					     =     json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()		)
        if pre_tok_state.get('''add_prefix_space'''     ,     lowercase__		) != add_prefix_space:
              _snake_case		:	int					     =     getattr(lowercase__     ,     pre_tok_state.pop('''type'''		)		)
              _snake_case		:	int					     =     add_prefix_space
              _snake_case		:	Optional[Any]					     =     pre_tok_class(**lowercase__		)

        _snake_case		:	List[str]					     =     add_prefix_space







  def 				UpperCAmelCase_				(		self     ,     lowercase__     ,     lowercase__ = None		)		->						Tuple[str]:






        """simple docstring"""





        _snake_case		:	Optional[int]					     =     self._tokenizer.model.save(lowercase__     ,     name=lowercase__		)
        return tuple(lowercase__		)







  def 				UpperCAmelCase_				(		self     ,     lowercase__		)		->						List[int]:






        """simple docstring"""





        _snake_case		:	List[str]					     =     []
        for is_user, text in conversation.iter_texts():
              input_ids.extend(self.encode(lowercase__     ,     add_special_tokens=lowercase__		) + [self.eos_token_id]		)

        if len(lowercase__		) > self.model_max_length:
              _snake_case		:	Dict					     =     input_ids[-self.model_max_length :]
        return input_ids


