


import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_splinter import SplinterTokenizer


lowerCamelCase		      = logging.get_logger(__name__)

lowerCamelCase		      = {'vocab_file': 'vocab.txt'}

lowerCamelCase		      = {
    'vocab_file': {
        'tau/splinter-base': 'https://huggingface.co/tau/splinter-base/resolve/main/vocab.txt',
        'tau/splinter-base-qass': 'https://huggingface.co/tau/splinter-base-qass/resolve/main/vocab.txt',
        'tau/splinter-large': 'https://huggingface.co/tau/splinter-large/resolve/main/vocab.txt',
        'tau/splinter-large-qass': 'https://huggingface.co/tau/splinter-large-qass/resolve/main/vocab.txt',
    }
}

lowerCamelCase		      = {
    'tau/splinter-base': 5_12,
    'tau/splinter-base-qass': 5_12,
    'tau/splinter-large': 5_12,
    'tau/splinter-large-qass': 5_12,
}

lowerCamelCase		      = {
    'tau/splinter-base': {'do_lower_case': False},
    'tau/splinter-base-qass': {'do_lower_case': False},
    'tau/splinter-large': {'do_lower_case': False},
    'tau/splinter-large-qass': {'do_lower_case': False},
}




class A						(     UpperCamelCase_  ):
						UpperCamelCase__							:						int   =VOCAB_FILES_NAMES
						UpperCamelCase__							:						Optional[int]   =PRETRAINED_VOCAB_FILES_MAP
						UpperCamelCase__							:						Union[str, Any]   =PRETRAINED_INIT_CONFIGURATION
						UpperCamelCase__							:						Optional[int]   =PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						UpperCamelCase__							:						Union[str, Any]   =SplinterTokenizer






						def __init__(      self		:  Optional[int]    ,     lowercase_		:  str=None    ,     lowercase_		:  Dict=None    ,     lowercase_		:  Dict=True    ,     lowercase_		:  Optional[Any]="[UNK]"    ,     lowercase_		:  Tuple="[SEP]"    ,     lowercase_		:  Tuple="[PAD]"    ,     lowercase_		:  Union[str, Any]="[CLS]"    ,     lowercase_		:  Union[str, Any]="[MASK]"    ,     lowercase_		:  Optional[Any]="[QUESTION]"    ,     lowercase_		:  Dict=True    ,     lowercase_		:  Dict=None    ,     **lowercase_		:  Tuple    ,     )      ->		List[str]:
													"""simple docstring"""




													super().__init__(
													    lowercase_    ,     tokenizer_file=lowercase_    ,     do_lower_case=lowercase_    ,     unk_token=lowercase_    ,     sep_token=lowercase_    ,     pad_token=lowercase_    ,     cls_token=lowercase_    ,     mask_token=lowercase_    ,     tokenize_chinese_chars=lowercase_    ,     strip_accents=lowercase_    ,     additional_special_tokens=(question_token,)    ,     **lowercase_    ,     )

													_lowerCamelCase :	List[str]						=json.loads(self.backend_tokenizer.normalizer.__getstate__()				)
													if (
													    pre_tok_state.get('lowercase'    ,     lowercase_				) != do_lower_case
													    or pre_tok_state.get('strip_accents'    ,     lowercase_				) != strip_accents
													):
																				_lowerCamelCase :	str						=getattr(lowercase_    ,     pre_tok_state.pop('type'				)				)
																				_lowerCamelCase :	Dict						=do_lower_case
																				_lowerCamelCase :	Optional[Any]						=strip_accents
																				_lowerCamelCase :	str						=pre_tok_class(**lowercase_				)

													_lowerCamelCase :	List[str]						=do_lower_case






						@property
						def  lowerCamelCase (      self		:  Dict				)      ->		Tuple:
													"""simple docstring"""




													return self.convert_tokens_to_ids(self.question_token				)






						def  lowerCamelCase (      self		:  int    ,     lowercase_		:  List[int]    ,     lowercase_		:  Optional[List[int]] = None				)      ->		List[int]:
													"""simple docstring"""




													if token_ids_a is None:
																				return [self.cls_token_id] + token_ids_a + [self.sep_token_id]

													_lowerCamelCase :	Any						=[self.cls_token_id]
													_lowerCamelCase :	Optional[int]						=[self.sep_token_id]
													_lowerCamelCase :	int						=[self.question_token_id] + [self.convert_tokens_to_ids('.'				)]
													if self.padding_side == "right":
																				# Input is question-then-context
																				return cls + token_ids_a + question_suffix + sep + token_ids_a + sep
													else:
																				# Input is context-then-question
																				return cls + token_ids_a + sep + token_ids_a + question_suffix + sep






						def  lowerCamelCase (      self		:  Any    ,     lowercase_		:  List[int]    ,     lowercase_		:  Optional[List[int]] = None				)      ->		List[int]:
													"""simple docstring"""




													_lowerCamelCase :	Tuple						=[self.sep_token_id]
													_lowerCamelCase :	Optional[int]						=[self.cls_token_id]
													_lowerCamelCase :	int						=[self.question_token_id] + [self.convert_tokens_to_ids('.'				)]
													if token_ids_a is None:
																				return len(cls + token_ids_a + sep				) * [0]

													if self.padding_side == "right":
																				# Input is question-then-context
																				return len(cls + token_ids_a + question_suffix + sep				) * [0] + len(token_ids_a + sep				) * [1]
													else:
																				# Input is context-then-question
																				return len(cls + token_ids_a + sep				) * [0] + len(token_ids_a + question_suffix + sep				) * [1]






						def  lowerCamelCase (      self		:  Optional[int]    ,     lowercase_		:  str    ,     lowercase_		:  Optional[str] = None				)      ->		Tuple[str]:
													"""simple docstring"""




													_lowerCamelCase :	List[Any]						=self._tokenizer.model.save(lowercase_    ,     name=lowercase_				)
													return tuple(lowercase_				)






from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import PIL
from PIL import Image

from ...utils import is_torch_available, is_transformers_available


if is_transformers_available() and is_torch_available():
 from .image_encoder import PaintByExampleImageEncoder
 from .pipeline_paint_by_example import PaintByExamplePipeline


