





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


UpperCAmelCase_  							=				logging.get_logger(__name__)

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

UpperCAmelCase_  							=				{
    '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 					lowercase__ (			__lowerCamelCase       ):

   '''simple docstring'''


   a		:							List[Any]								=	VOCAB_FILES_NAMES
   a		:							Optional[int]								=	PRETRAINED_VOCAB_FILES_MAP
   a		:							Union[str, Any]								=	["input_ids", "attention_mask"]
   a		:							str								=	None




   def __init__(					self,	__magic_name__=None,	__magic_name__=None,	__magic_name__=None,	__magic_name__="<unk>",	__magic_name__="<s>",	__magic_name__="</s>",	__magic_name__="<pad>",	__magic_name__=False,	__magic_name__=False,	**__magic_name__,	)				->   str:






       """simple docstring"""
       super().__init__(
           __magic_name__,	__magic_name__,	tokenizer_file=__magic_name__,	unk_token=__magic_name__,	bos_token=__magic_name__,	eos_token=__magic_name__,	pad_token=__magic_name__,	add_prefix_space=__magic_name__,	clean_up_tokenization_spaces=__magic_name__,	**__magic_name__,	)
       UpperCamelCase__							:       Any      =   json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()							)
       if pre_tok_state.get('''add_prefix_space''',	__magic_name__							) != add_prefix_space:
           UpperCamelCase__							:       int      =   getattr(__magic_name__,	pre_tok_state.pop('''type'''							)							)
           UpperCamelCase__							:       str      =   add_prefix_space
           UpperCamelCase__							:       Dict      =   pre_tok_class(**__magic_name__							)

       UpperCamelCase__							:       Union[str, Any]      =   add_prefix_space




   def    UpperCamelCase__						(					self,	*__magic_name__,	**__magic_name__							)				->   BatchEncoding:






       """simple docstring"""
       UpperCamelCase__							:       List[str]      =   kwargs.get('''is_split_into_words''',	__magic_name__							)
       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(*__magic_name__,	**__magic_name__							)




   def    UpperCamelCase__						(					self,	*__magic_name__,	**__magic_name__							)				->   BatchEncoding:






       """simple docstring"""
       UpperCamelCase__							:       List[Any]      =   kwargs.get('''is_split_into_words''',	__magic_name__							)

       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(*__magic_name__,	**__magic_name__							)




   def    UpperCamelCase__						(					self,	__magic_name__,	__magic_name__ = None							)				->   Tuple[str]:






       """simple docstring"""
       UpperCamelCase__							:       List[Any]      =   self._tokenizer.model.save(__magic_name__,	name=__magic_name__							)
       return tuple(__magic_name__							)




   def    UpperCamelCase__						(					self,	__magic_name__							)				->   List[int]:






       """simple docstring"""
       UpperCamelCase__							:       List[Any]      =   []
       for is_user, text in conversation.iter_texts():
           input_ids.extend(self.encode(__magic_name__,	add_special_tokens=__magic_name__							) + [self.eos_token_id]							)

       if len(__magic_name__							) > self.model_max_length:
           UpperCamelCase__							:       List[Any]      =   input_ids[-self.model_max_length :]
       return input_ids








import logging
from dataclasses import dataclass, field
from pathlib import Path
from typing import Optional, Union

from .generation.configuration_utils import GenerationConfig
from .training_args import TrainingArguments
from .utils import add_start_docstrings


UpperCAmelCase_  							=				logging.getLogger(__name__)






@dataclass
@add_start_docstrings(TrainingArguments.__doc__       )
class 					lowercase__ (			__lowerCamelCase       ):

   '''simple docstring'''


   a		:							bool     	=	field(default=__lowerCamelCase    ,       metadata={"help": "Whether to use SortishSampler or not."}       )
   a		:							bool     	=	field(
       default=__lowerCamelCase    ,       metadata={"help": "Whether to use generate to calculate generative metrics (ROUGE, BLEU)."}       )
   a		:							Optional[int]     	=	field(
       default=__lowerCamelCase    ,       metadata={
           "help": (
               "The `max_length` to use on each evaluation loop when `predict_with_generate=True`. Will default "
               "to the `max_length` value of the model configuration."
           )
       }    ,       )
   a		:							Optional[int]     	=	field(
       default=__lowerCamelCase    ,       metadata={
           "help": (
               "The `num_beams` to use on each evaluation loop when `predict_with_generate=True`. Will default "
               "to the `num_beams` value of the model configuration."
           )
       }    ,       )
   a		:							Optional[Union[str, Path, GenerationConfig]]     	=	field(
       default=__lowerCamelCase    ,       metadata={
           "help": "Model id, file path or url pointing to a GenerationConfig json file, to use during prediction."
       }    ,       )




   def    UpperCamelCase__						(					self							)				->   str:






       """simple docstring"""
       UpperCamelCase__							:       Tuple      =   super().to_dict()
       for k, v in d.items():
           if isinstance(__magic_name__,	__magic_name__							):
               UpperCamelCase__							:       Tuple      =   v.to_dict()
       return d

