'''simple docstring'''






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

from tokenizers import pre_tokenizers

from ...tokenization_utils_base import BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging


if TYPE_CHECKING:
     from transformers.pipelines.conversational import Conversation


__a										=					logging.get_logger(__name__)

__a										=					{'tokenizer_file': 'tokenizer.json'}

__a										=					{
    'tokenizer_file': {
        'bigscience/tokenizer': 'https://huggingface.co/bigscience/tokenizer/blob/main/tokenizer.json',
        'bigscience/bloom-560m': 'https://huggingface.co/bigscience/bloom-560m/blob/main/tokenizer.json',
        'bigscience/bloom-1b1': 'https://huggingface.co/bigscience/bloom-1b1/blob/main/tokenizer.json',
        'bigscience/bloom-1b7': 'https://huggingface.co/bigscience/bloom-1b7/blob/main/tokenizer.json',
        'bigscience/bloom-3b': 'https://huggingface.co/bigscience/bloom-3b/blob/main/tokenizer.json',
        'bigscience/bloom-7b1': 'https://huggingface.co/bigscience/bloom-7b1/blob/main/tokenizer.json',
        'bigscience/bloom': 'https://huggingface.co/bigscience/bloom/blob/main/tokenizer.json',
    },
}





class     A__							(       UpperCamelCase__   ):





   """simple docstring"""





   UpperCamelCase_       :						int    				=     VOCAB_FILES_NAMES
   UpperCamelCase_       :						Dict    				=     PRETRAINED_VOCAB_FILES_MAP
   UpperCamelCase_       :						Any    				=     ["""input_ids""", """attention_mask"""]
   UpperCamelCase_       :						Any    				=     None




   def __init__( self     :		Optional[int]						,     lowerCAmelCase__     :		Optional[int]=None						,     lowerCAmelCase__     :		Union[str, Any]=None						,     lowerCAmelCase__     :		Dict=None						,     lowerCAmelCase__     :		List[Any]="<unk>"						,     lowerCAmelCase__     :		Union[str, Any]="<s>"						,     lowerCAmelCase__     :		Any="</s>"						,     lowerCAmelCase__     :		int="<pad>"						,     lowerCAmelCase__     :		str=False						,     lowerCAmelCase__     :		str=False						,     **lowerCAmelCase__     :		int						,     )       ->    Tuple:







      """simple docstring"""




      super().__init__(
          __a						,     __a						,     tokenizer_file=__a						,     unk_token=__a						,     bos_token=__a						,     eos_token=__a						,     pad_token=__a						,     add_prefix_space=__a						,     clean_up_tokenization_spaces=__a						,     **__a						,     )
      _UpperCAmelCase							:	Dict							=   json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()			)
      if pre_tok_state.get("add_prefix_space"						,     __a			) != add_prefix_space:
         _UpperCAmelCase							:	List[str]							=   getattr(__a						,     pre_tok_state.pop("type"			)			)
         _UpperCAmelCase							:	Optional[Any]							=   add_prefix_space
         _UpperCAmelCase							:	int							=   pre_tok_class(**__a			)

      _UpperCAmelCase							:	Union[str, Any]							=   add_prefix_space




   def 			_lowerCAmelCase		( self     :		Tuple						,     *lowerCAmelCase__     :		Optional[Any]						,     **lowerCAmelCase__     :		str			)       ->    Optional[Any]:







      """simple docstring"""




      _UpperCAmelCase							:	Any							=   kwargs.get("is_split_into_words"						,     __a			)
      if not (self.add_prefix_space or not is_split_into_words):
         raise Exception(
             F"""You need to instantiate {self.__class__.__name__} with add_prefix_space=True to use it with"""
             " pretokenized inputs."			)

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




   def 			_lowerCAmelCase		( self     :		Tuple						,     *lowerCAmelCase__     :		Tuple						,     **lowerCAmelCase__     :		int			)       ->    Any:







      """simple docstring"""




      _UpperCAmelCase							:	List[Any]							=   kwargs.get("is_split_into_words"						,     __a			)

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

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




   def 			_lowerCAmelCase		( self     :		Optional[int]						,     lowerCAmelCase__     :		str						,     lowerCAmelCase__     :		Optional[str] = None			)       ->    Any:







      """simple docstring"""




      _UpperCAmelCase							:	Any							=   self._tokenizer.model.save(__a						,     name=__a			)
      return tuple(__a			)




   def 			_lowerCAmelCase		( self     :		Optional[int]						,     lowerCAmelCase__     :		"Conversation"			)       ->    Union[str, Any]:







      """simple docstring"""




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

      if len(__a			) > self.model_max_length:
         _UpperCAmelCase							:	Optional[int]							=   input_ids[-self.model_max_length :]
      return input_ids
'''simple docstring'''





from ...configuration_utils import PretrainedConfig
from ...utils import logging


SCREAMING_SNAKE_CASE_:     Dict  =logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_:     Tuple  ={}




class        __A      ( UpperCamelCase__	):
    a__       :						int          =  """llama"""
    a__       :						Any          =  ["""past_key_values"""]



    def __init__(self    :    List[str]   ,			__a    :    List[str]=32000   ,			__a    :    Tuple=4096   ,			__a    :    List[Any]=11008   ,			__a    :    Dict=32   ,			__a    :    Tuple=32   ,			__a    :    Any=None   ,			__a    :    Any="silu"   ,			__a    :    List[Any]=2048   ,			__a    :    List[Any]=0.02   ,			__a    :    str=1E-6   ,			__a    :    Optional[Any]=True   ,			__a    :    Union[str, Any]=0   ,			__a    :    Any=1   ,			__a    :    Dict=2   ,			__a    :    Dict=1   ,			__a    :    str=False   ,			__a    :    str=None   ,			**__a    :    Optional[Any]   ,			):
         UpperCAmelCase_           =   vocab_size
         UpperCAmelCase_           =   max_position_embeddings
         UpperCAmelCase_           =   hidden_size
         UpperCAmelCase_           =   intermediate_size
         UpperCAmelCase_           =   num_hidden_layers
         UpperCAmelCase_           =   num_attention_heads

         # for backward compatibility
         if num_key_value_heads is None:
              UpperCAmelCase_           =   num_attention_heads

         UpperCAmelCase_           =   num_key_value_heads
         UpperCAmelCase_           =   hidden_act
         UpperCAmelCase_           =   initializer_range
         UpperCAmelCase_           =   rms_norm_eps
         UpperCAmelCase_           =   pretraining_tp
         UpperCAmelCase_           =   use_cache
         UpperCAmelCase_           =   rope_scaling
         self._rope_scaling_validation()

         super().__init__(
             pad_token_id=__a   ,			bos_token_id=__a   ,			eos_token_id=__a   ,			tie_word_embeddings=__a   ,			**__a   ,			)






    def 					_lowercase						(self    :    List[str] ):
         if self.rope_scaling is None:
              return

         if not isinstance(self.rope_scaling   ,			__a ) or len(self.rope_scaling ) != 2:
              raise ValueError(
                  "`rope_scaling` must be a dictionary with with two fields, `name` and `factor`, "
                  f"""got {self.rope_scaling}""" )
         UpperCAmelCase_           =   self.rope_scaling.get("type"   ,			__a )
         UpperCAmelCase_           =   self.rope_scaling.get("factor"   ,			__a )
         if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
              raise ValueError(
                  f"""`rope_scaling`'s name field must be one of ['linear', 'dynamic'], got {rope_scaling_type}""" )
         if rope_scaling_factor is None or not isinstance(__a   ,			__a ) or rope_scaling_factor <= 1.0:
              raise ValueError(f"""`rope_scaling`'s factor field must be an float > 1, got {rope_scaling_factor}""" )




