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


UpperCamelCase      			=     logging.get_logger(__name__)

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

UpperCamelCase      			=     {
    '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',
    }
}

UpperCamelCase      			=     {
    'tau/splinter-base': 512,
    'tau/splinter-base-qass': 512,
    'tau/splinter-large': 512,
    'tau/splinter-large-qass': 512,
}

UpperCamelCase      			=     {
    '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       (	lowerCAmelCase__ ):

	'''simple docstring'''



	lowerCamelCase_   :      Optional[Any]       =	VOCAB_FILES_NAMES
	lowerCamelCase_   :      int       =	PRETRAINED_VOCAB_FILES_MAP
	lowerCamelCase_   :      Dict       =	PRETRAINED_INIT_CONFIGURATION
	lowerCamelCase_   :      Optional[int]       =	PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	lowerCamelCase_   :      Optional[Any]       =	SplinterTokenizer

	def __init__(       self							,			__UpperCAmelCase=None							,			__UpperCAmelCase=None							,			__UpperCAmelCase=True							,			__UpperCAmelCase="[UNK]"							,			__UpperCAmelCase="[SEP]"							,			__UpperCAmelCase="[PAD]"							,			__UpperCAmelCase="[CLS]"							,			__UpperCAmelCase="[MASK]"							,			__UpperCAmelCase="[QUESTION]"							,			__UpperCAmelCase=True							,			__UpperCAmelCase=None							,			**__UpperCAmelCase							,			):
			super().__init__(
			    __UpperCAmelCase							,			tokenizer_file=__UpperCAmelCase							,			do_lower_case=__UpperCAmelCase							,			unk_token=__UpperCAmelCase							,			sep_token=__UpperCAmelCase							,			pad_token=__UpperCAmelCase							,			cls_token=__UpperCAmelCase							,			mask_token=__UpperCAmelCase							,			tokenize_chinese_chars=__UpperCAmelCase							,			strip_accents=__UpperCAmelCase							,			additional_special_tokens=(question_token,)							,			**__UpperCAmelCase							,			)

			__A							:   Optional[Any]	  =				json.loads(self.backend_tokenizer.normalizer.__getstate__()   )
			if (
			    pre_tok_state.get("lowercase"							,			__UpperCAmelCase   ) != do_lower_case
			    or pre_tok_state.get("strip_accents"							,			__UpperCAmelCase   ) != strip_accents
			):
					__A							:   Tuple	  =				getattr(__UpperCAmelCase							,			pre_tok_state.pop("type"   )   )
					__A							:   List[Any]	  =				do_lower_case
					__A							:   List[str]	  =				strip_accents
					__A							:   Union[str, Any]	  =				pre_tok_class(**__UpperCAmelCase   )

			__A							:   int	  =				do_lower_case

	@property
	def 					__UpperCAmelCase(       self   ):
			return self.convert_tokens_to_ids(self.question_token   )

	def 					__UpperCAmelCase(       self							,			__UpperCAmelCase							,			__UpperCAmelCase = None   ):
			if token_ids_a is None:
					return [self.cls_token_id] + token_ids_a + [self.sep_token_id]

			__A							:   Any	  =				[self.cls_token_id]
			__A							:   int	  =				[self.sep_token_id]
			__A							:   List[Any]	  =				[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 					__UpperCAmelCase(       self							,			__UpperCAmelCase							,			__UpperCAmelCase = None   ):
			__A							:   Dict	  =				[self.sep_token_id]
			__A							:   Tuple	  =				[self.cls_token_id]
			__A							:   List[Any]	  =				[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 					__UpperCAmelCase(       self							,			__UpperCAmelCase							,			__UpperCAmelCase = None   ):
			__A							:   List[Any]	  =				self._tokenizer.model.save(__UpperCAmelCase							,			name=__UpperCAmelCase   )
			return tuple(__UpperCAmelCase   )






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





