


'''simple docstring'''




import colorsys
import io

import cva
import matplotlib as mpl
import matplotlib.colors as mplc
import matplotlib.figure as mplfigure
import numpy as np
import torch
from matplotlib.backends.backend_agg import FigureCanvasAgg

from utils import img_tensorize


__lowercase  :      Dict      		=				10_00





class _snake_case   :
							"""simple docstring"""





							def __init__(   self			,				__A			,				__A=1.2			,				__A="g"			,				__A=0.5			,				__A="-"			,				__A="test_out.jpg"			,				__A=True			,				__A=False			,				__A=None			,				__A=None			,				__A=0.7			,				)     ->Optional[Any]:



											"""simple docstring"""







											if isinstance(__A			,				torch.Tensor	):
															__lowerCamelCase		:      int											=					img.numpy().astype("np.uint8"	)
											if isinstance(__A			,				__A	):
															__lowerCamelCase		:      Tuple											=					img_tensorize(__A	)
											assert isinstance(__A			,				np.ndarray	)

											__lowerCamelCase		:      str											=					img.shape[1], img.shape[0]
											__lowerCamelCase		:      Optional[int]											=					mplfigure.Figure(frameon=__A	)
											__lowerCamelCase		:      Optional[int]											=					fig.get_dpi()
											__lowerCamelCase		:      Dict											=					(width * scale + 1E-2) / dpi
											__lowerCamelCase		:      Union[str, Any]											=					(height * scale + 1E-2) / dpi
											fig.set_size_inches(__A			,				__A	)
											__lowerCamelCase		:      List[Any]											=					fig.add_axes([0.0, 0.0, 1.0, 1.0]	)
											ax.axis("off"	)
											ax.set_xlim(0.0			,				__A	)
											ax.set_ylim(__A	)

											__lowerCamelCase		:      str											=					saveas
											__lowerCamelCase		:      Optional[Any]											=					rgb
											__lowerCamelCase		:      Union[str, Any]											=					pynb
											__lowerCamelCase		:      Optional[Any]											=					img
											__lowerCamelCase		:      List[Any]											=					edgecolor
											__lowerCamelCase		:      Any											=					0.5
											__lowerCamelCase		:      List[str]											=					linestyle
											__lowerCamelCase		:      Tuple											=					int(np.sqrt(min(__A			,				__A	)	) * scale // 3	)
											__lowerCamelCase		:      str											=					width
											__lowerCamelCase		:      Optional[int]											=					height
											__lowerCamelCase		:      List[Any]											=					scale
											__lowerCamelCase		:      Union[str, Any]											=					fig
											__lowerCamelCase		:      Tuple											=					ax
											__lowerCamelCase		:      List[Any]											=					pad
											__lowerCamelCase		:      Union[str, Any]											=					idaobj
											__lowerCamelCase		:      Optional[int]											=					idaattr
											__lowerCamelCase		:      Dict											=					FigureCanvasAgg(__A	)







							def 		__SCREAMING_SNAKE_CASE(   self			,				__A			,				__A=None	)     ->Optional[Any]:



											"""simple docstring"""







											if color is None:
															__lowerCamelCase		:      Any											=					self.edgecolor
											(__lowerCamelCase)		:      Union[str, Any]											=					box
											__lowerCamelCase		:      Optional[Any]											=					xa - xa
											__lowerCamelCase		:      Any											=					ya - ya
											self.ax.add_patch(
											    mpl.patches.Rectangle(
											        (xa, ya)			,				__A			,				__A			,				fill=__A			,				edgecolor=__A			,				linewidth=self.font_size // 3			,				alpha=self.alpha			,				linestyle=self.linestyle			,				)	)







							def 		__SCREAMING_SNAKE_CASE(   self			,				__A			,				__A=None			,				__A=None			,				__A=None			,				__A=None	)     ->Any:



											"""simple docstring"""







											if len(boxes.shape	) > 2:
															__lowerCamelCase		:      Union[str, Any]											=					boxes[0]
											if len(obj_ids.shape	) > 1:
															__lowerCamelCase		:      List[Any]											=					obj_ids[0]
											if len(obj_scores.shape	) > 1:
															__lowerCamelCase		:      Optional[Any]											=					obj_scores[0]
											if len(attr_ids.shape	) > 1:
															__lowerCamelCase		:      str											=					attr_ids[0]
											if len(attr_scores.shape	) > 1:
															__lowerCamelCase		:      str											=					attr_scores[0]
											if isinstance(__A			,				torch.Tensor	):
															__lowerCamelCase		:      List[str]											=					boxes.numpy()
											if isinstance(__A			,				__A	):
															__lowerCamelCase		:      Optional[Any]											=					np.array(__A	)
											assert isinstance(__A			,				np.ndarray	)
											__lowerCamelCase		:      Union[str, Any]											=					np.prod(boxes[:, 2:] - boxes[:, :2]			,				axis=1	)
											__lowerCamelCase		:      int											=					np.argsort(-areas	).tolist()
											__lowerCamelCase		:      List[Any]											=					boxes[sorted_idxs] if boxes is not None else None
											__lowerCamelCase		:      List[Any]											=					obj_ids[sorted_idxs] if obj_ids is not None else None
											__lowerCamelCase		:      str											=					obj_scores[sorted_idxs] if obj_scores is not None else None
											__lowerCamelCase		:      int											=					attr_ids[sorted_idxs] if attr_ids is not None else None
											__lowerCamelCase		:      Dict											=					attr_scores[sorted_idxs] if attr_scores is not None else None

											__lowerCamelCase		:      Any											=					[self._random_color(maximum=1	) for _ in range(len(__A	)	)]
											__lowerCamelCase		:      Tuple											=					[assigned_colors[idx] for idx in sorted_idxs]
											if obj_ids is not None:
															__lowerCamelCase		:      Union[str, Any]											=					self._create_text_labels_attr(__A			,				__A			,				__A			,				__A	)
															for i in range(len(__A	)	):
																			__lowerCamelCase		:      Optional[int]											=					assigned_colors[i]
																			self.add_box(boxes[i]			,				__A	)
																			self.draw_labels(labels[i]			,				boxes[i]			,				__A	)







							def 		__SCREAMING_SNAKE_CASE(   self			,				__A			,				__A			,				__A	)     ->Optional[Any]:



											"""simple docstring"""







											__lowerCamelCase		:      Union[str, Any]											=					box
											__lowerCamelCase		:      Dict											=					(xa, ya)
											__lowerCamelCase		:      int											=					(ya - ya) * (xa - xa)
											__lowerCamelCase		:      Optional[int]											=					_SMALL_OBJ * self.scale
											if instance_area < small or ya - ya < 40 * self.scale:
															if ya >= self.height - 5:
																			__lowerCamelCase		:      Union[str, Any]											=					(xa, ya)
															else:
																			__lowerCamelCase		:      Tuple											=					(xa, ya)

											__lowerCamelCase		:      Union[str, Any]											=					(ya - ya) / np.sqrt(self.height * self.width	)
											__lowerCamelCase		:      Optional[Any]											=					self._change_color_brightness(__A			,				brightness_factor=0.7	)
											__lowerCamelCase		:      Optional[int]											=					np.clip((height_ratio - 0.02) / 0.08 + 1			,				1.2			,				2	)
											font_size *= 0.75 * self.font_size

											self.draw_text(
											    text=__A			,				position=__A			,				color=__A			,				)







							def 		__SCREAMING_SNAKE_CASE(   self			,				__A			,				__A			,				__A="g"			,				__A="left"			,				)     ->Tuple:



											"""simple docstring"""







											__lowerCamelCase		:      Union[str, Any]											=					0
											__lowerCamelCase		:      int											=					self.font_size
											__lowerCamelCase		:      Union[str, Any]											=					np.maximum(list(mplc.to_rgb(__A	)	)			,				0.2	)
											__lowerCamelCase		:      Any											=					max(0.8			,				np.max(__A	)	)
											__lowerCamelCase		:      Optional[Any]											=					{
											    "facecolor": "black",
											    "alpha": self.alpha,
											    "pad": self.pad,
											    "edgecolor": "none",
											}
											__lowerCamelCase		:      Optional[int]											=					position
											self.ax.text(
											    __A			,				__A			,				__A			,				size=font_size * self.scale			,				family="sans-serif"			,				bbox=__A			,				verticalalignment="top"			,				horizontalalignment=__A			,				color=__A			,				zorder=10			,				rotation=__A			,				)







							def 		__SCREAMING_SNAKE_CASE(   self			,				__A=None	)     ->List[str]:



											"""simple docstring"""







											if saveas is None:
															__lowerCamelCase		:      int											=					self.saveas
											if saveas.lower().endswith(".jpg"	) or saveas.lower().endswith(".png"	):
															cva.imwrite(
															    __A			,				self._get_buffer()[:, :, ::-1]			,				)
											else:
															self.fig.savefig(__A	)







							def 		__SCREAMING_SNAKE_CASE(   self			,				__A			,				__A			,				__A			,				__A	)     ->Any:



											"""simple docstring"""







											__lowerCamelCase		:      str											=					[self.idaobj[i] for i in classes]
											__lowerCamelCase		:      Tuple											=					[self.idaattr[i] for i in attr_classes]
											__lowerCamelCase		:      List[str]											=					[
											    f'{label} {score:.2f} {attr} {attr_score:.2f}'
											    for label, score, attr, attr_score in zip(__A			,				__A			,				__A			,				__A	)
											]
											return labels







							def 		__SCREAMING_SNAKE_CASE(   self			,				__A			,				__A	)     ->Union[str, Any]:



											"""simple docstring"""







											__lowerCamelCase		:      Optional[int]											=					[self.idaobj[i] for i in classes]
											if scores is not None:
															if labels is None:
																			__lowerCamelCase		:      str											=					["{:.0f}%".format(s * 100	) for s in scores]
															else:
																			__lowerCamelCase		:      List[Any]											=					["{} {:.0f}%".format(__A			,				s * 100	) for li, s in zip(__A			,				__A	)]
											return labels







							def 		__SCREAMING_SNAKE_CASE(   self			,				__A=255	)     ->int:



											"""simple docstring"""







											__lowerCamelCase		:      Optional[Any]											=					np.random.randint(0			,				len(_COLORS	)	)
											__lowerCamelCase		:      int											=					_COLORS[idx] * maximum
											if not self.rgb:
															__lowerCamelCase		:      Tuple											=					ret[::-1]
											return ret







							def 		__SCREAMING_SNAKE_CASE(   self	)     ->int:



											"""simple docstring"""







											if not self.pynb:
															__lowerCamelCase		:      int											=					self.canvas.print_to_buffer()
															if (width, height) != (self.width, self.height):
																			__lowerCamelCase		:      Optional[Any]											=					cva.resize(self.img			,				(width, height)	)
															else:
																			__lowerCamelCase		:      int											=					self.img
											else:
															__lowerCamelCase		:      Optional[int]											=					io.BytesIO()  # works for cairo backend
															self.canvas.print_rgba(__A	)
															__lowerCamelCase		:      str											=					self.width, self.height
															__lowerCamelCase		:      Optional[int]											=					buf.getvalue()
															__lowerCamelCase		:      Tuple											=					self.img

											__lowerCamelCase		:      Dict											=					np.frombuffer(__A			,				dtype="uint8"	)
											__lowerCamelCase		:      Any											=					buffer.reshape(__A			,				__A			,				4	)
											__lowerCamelCase		:      Optional[Any]											=					np.split(__A			,				[3]			,				axis=2	)

											try:
															import numexpr as ne  # fuse them with numexpr

															__lowerCamelCase		:      Any											=					ne.evaluate("img * (1 - alpha / 255.0) + rgb * (alpha / 255.0)"	)
											except ImportError:
															__lowerCamelCase		:      List[Any]											=					alpha.astype("float32"	) / 255.0
															__lowerCamelCase		:      Tuple											=					img * (1 - alpha) + rgb * alpha

											return visualized_image.astype("uint8"	)







							def 		__SCREAMING_SNAKE_CASE(   self			,				__A			,				__A	)     ->List[Any]:



											"""simple docstring"""







											assert brightness_factor >= -1.0 and brightness_factor <= 1.0
											__lowerCamelCase		:      Optional[int]											=					mplc.to_rgb(__A	)
											__lowerCamelCase		:      Tuple											=					colorsys.rgb_to_hls(*mplc.to_rgb(__A	)	)
											__lowerCamelCase		:      Dict											=					polygon_color[1] + (brightness_factor * polygon_color[1])
											__lowerCamelCase		:      Optional[int]											=					0.0 if modified_lightness < 0.0 else modified_lightness
											__lowerCamelCase		:      str											=					1.0 if modified_lightness > 1.0 else modified_lightness
											__lowerCamelCase		:      str											=					colorsys.hls_to_rgb(polygon_color[0]			,				__A			,				polygon_color[2]	)
											return modified_color

__lowercase  :      List[Any]      		=				(
    np.array(
        [
            0.0_00,
            0.4_47,
            0.7_41,
            0.8_50,
            0.3_25,
            0.0_98,
            0.9_29,
            0.6_94,
            0.1_25,
            0.4_94,
            0.1_84,
            0.5_56,
            0.4_66,
            0.6_74,
            0.1_88,
            0.3_01,
            0.7_45,
            0.9_33,
            0.6_35,
            0.0_78,
            0.1_84,
            0.3_00,
            0.3_00,
            0.3_00,
            0.6_00,
            0.6_00,
            0.6_00,
            1.0_00,
            0.0_00,
            0.0_00,
            1.0_00,
            0.5_00,
            0.0_00,
            0.7_49,
            0.7_49,
            0.0_00,
            0.0_00,
            1.0_00,
            0.0_00,
            0.0_00,
            0.0_00,
            1.0_00,
            0.6_67,
            0.0_00,
            1.0_00,
            0.3_33,
            0.3_33,
            0.0_00,
            0.3_33,
            0.6_67,
            0.0_00,
            0.3_33,
            1.0_00,
            0.0_00,
            0.6_67,
            0.3_33,
            0.0_00,
            0.6_67,
            0.6_67,
            0.0_00,
            0.6_67,
            1.0_00,
            0.0_00,
            1.0_00,
            0.3_33,
            0.0_00,
            1.0_00,
            0.6_67,
            0.0_00,
            1.0_00,
            1.0_00,
            0.0_00,
            0.0_00,
            0.3_33,
            0.5_00,
            0.0_00,
            0.6_67,
            0.5_00,
            0.0_00,
            1.0_00,
            0.5_00,
            0.3_33,
            0.0_00,
            0.5_00,
            0.3_33,
            0.3_33,
            0.5_00,
            0.3_33,
            0.6_67,
            0.5_00,
            0.3_33,
            1.0_00,
            0.5_00,
            0.6_67,
            0.0_00,
            0.5_00,
            0.6_67,
            0.3_33,
            0.5_00,
            0.6_67,
            0.6_67,
            0.5_00,
            0.6_67,
            1.0_00,
            0.5_00,
            1.0_00,
            0.0_00,
            0.5_00,
            1.0_00,
            0.3_33,
            0.5_00,
            1.0_00,
            0.6_67,
            0.5_00,
            1.0_00,
            1.0_00,
            0.5_00,
            0.0_00,
            0.3_33,
            1.0_00,
            0.0_00,
            0.6_67,
            1.0_00,
            0.0_00,
            1.0_00,
            1.0_00,
            0.3_33,
            0.0_00,
            1.0_00,
            0.3_33,
            0.3_33,
            1.0_00,
            0.3_33,
            0.6_67,
            1.0_00,
            0.3_33,
            1.0_00,
            1.0_00,
            0.6_67,
            0.0_00,
            1.0_00,
            0.6_67,
            0.3_33,
            1.0_00,
            0.6_67,
            0.6_67,
            1.0_00,
            0.6_67,
            1.0_00,
            1.0_00,
            1.0_00,
            0.0_00,
            1.0_00,
            1.0_00,
            0.3_33,
            1.0_00,
            1.0_00,
            0.6_67,
            1.0_00,
            0.3_33,
            0.0_00,
            0.0_00,
            0.5_00,
            0.0_00,
            0.0_00,
            0.6_67,
            0.0_00,
            0.0_00,
            0.8_33,
            0.0_00,
            0.0_00,
            1.0_00,
            0.0_00,
            0.0_00,
            0.0_00,
            0.1_67,
            0.0_00,
            0.0_00,
            0.3_33,
            0.0_00,
            0.0_00,
            0.5_00,
            0.0_00,
            0.0_00,
            0.6_67,
            0.0_00,
            0.0_00,
            0.8_33,
            0.0_00,
            0.0_00,
            1.0_00,
            0.0_00,
            0.0_00,
            0.0_00,
            0.1_67,
            0.0_00,
            0.0_00,
            0.3_33,
            0.0_00,
            0.0_00,
            0.5_00,
            0.0_00,
            0.0_00,
            0.6_67,
            0.0_00,
            0.0_00,
            0.8_33,
            0.0_00,
            0.0_00,
            1.0_00,
            0.0_00,
            0.0_00,
            0.0_00,
            0.1_43,
            0.1_43,
            0.1_43,
            0.8_57,
            0.8_57,
            0.8_57,
            1.0_00,
            1.0_00,
            1.0_00,
        ]
    )
    .astype(np.floataa)
    .reshape(-1, 3)
)









'''simple docstring'''




import json
from typing import List, Optional, Tuple

from tokenizers import pre_tokenizers, processors

from ...tokenization_utils_base import AddedToken, BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_longformer import LongformerTokenizer


__lowercase  :      str      		=				logging.get_logger(__name__)

__lowercase  :      Any      		=				{"""vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", """tokenizer_file""": """tokenizer.json"""}

__lowercase  :      Optional[Any]      		=				{
    """vocab_file""": {
        """allenai/longformer-base-4096""": """https://huggingface.co/allenai/longformer-base-4096/resolve/main/vocab.json""",
        """allenai/longformer-large-4096""": (
            """https://huggingface.co/allenai/longformer-large-4096/resolve/main/vocab.json"""
        ),
        """allenai/longformer-large-4096-finetuned-triviaqa""": (
            """https://huggingface.co/allenai/longformer-large-4096-finetuned-triviaqa/resolve/main/vocab.json"""
        ),
        """allenai/longformer-base-4096-extra.pos.embd.only""": (
            """https://huggingface.co/allenai/longformer-base-4096-extra.pos.embd.only/resolve/main/vocab.json"""
        ),
        """allenai/longformer-large-4096-extra.pos.embd.only""": (
            """https://huggingface.co/allenai/longformer-large-4096-extra.pos.embd.only/resolve/main/vocab.json"""
        ),
    },
    """merges_file""": {
        """allenai/longformer-base-4096""": """https://huggingface.co/allenai/longformer-base-4096/resolve/main/merges.txt""",
        """allenai/longformer-large-4096""": (
            """https://huggingface.co/allenai/longformer-large-4096/resolve/main/merges.txt"""
        ),
        """allenai/longformer-large-4096-finetuned-triviaqa""": (
            """https://huggingface.co/allenai/longformer-large-4096-finetuned-triviaqa/resolve/main/merges.txt"""
        ),
        """allenai/longformer-base-4096-extra.pos.embd.only""": (
            """https://huggingface.co/allenai/longformer-base-4096-extra.pos.embd.only/resolve/main/merges.txt"""
        ),
        """allenai/longformer-large-4096-extra.pos.embd.only""": (
            """https://huggingface.co/allenai/longformer-large-4096-extra.pos.embd.only/resolve/main/merges.txt"""
        ),
    },
    """tokenizer_file""": {
        """allenai/longformer-base-4096""": (
            """https://huggingface.co/allenai/longformer-base-4096/resolve/main/tokenizer.json"""
        ),
        """allenai/longformer-large-4096""": (
            """https://huggingface.co/allenai/longformer-large-4096/resolve/main/tokenizer.json"""
        ),
        """allenai/longformer-large-4096-finetuned-triviaqa""": (
            """https://huggingface.co/allenai/longformer-large-4096-finetuned-triviaqa/resolve/main/tokenizer.json"""
        ),
        """allenai/longformer-base-4096-extra.pos.embd.only""": (
            """https://huggingface.co/allenai/longformer-base-4096-extra.pos.embd.only/resolve/main/tokenizer.json"""
        ),
        """allenai/longformer-large-4096-extra.pos.embd.only""": (
            """https://huggingface.co/allenai/longformer-large-4096-extra.pos.embd.only/resolve/main/tokenizer.json"""
        ),
    },
}

__lowercase  :      Tuple      		=				{
    """allenai/longformer-base-4096""": 40_96,
    """allenai/longformer-large-4096""": 40_96,
    """allenai/longformer-large-4096-finetuned-triviaqa""": 40_96,
    """allenai/longformer-base-4096-extra.pos.embd.only""": 40_96,
    """allenai/longformer-large-4096-extra.pos.embd.only""": 40_96,
}





class _snake_case   ( a__   ):
							"""simple docstring"""





							__a												=     VOCAB_FILES_NAMES
							__a												=     PRETRAINED_VOCAB_FILES_MAP
							__a												=     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							__a												=     ['''input_ids''', '''attention_mask''']
							__a												=     LongformerTokenizer







							def __init__(   self			,				__A=None			,				__A=None			,				__A=None			,				__A="replace"			,				__A="<s>"			,				__A="</s>"			,				__A="</s>"			,				__A="<s>"			,				__A="<unk>"			,				__A="<pad>"			,				__A="<mask>"			,				__A=False			,				__A=True			,				**__A			,				)     ->Dict:



											"""simple docstring"""







											super().__init__(
											    __A			,				__A			,				tokenizer_file=__A			,				errors=__A			,				bos_token=__A			,				eos_token=__A			,				sep_token=__A			,				cls_token=__A			,				unk_token=__A			,				pad_token=__A			,				mask_token=__A			,				add_prefix_space=__A			,				trim_offsets=__A			,				**__A			,				)

											__lowerCamelCase		:      int											=					json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()	)
											if pre_tok_state.get("add_prefix_space"			,				__A	) != add_prefix_space:
															__lowerCamelCase		:      Any											=					getattr(__A			,				pre_tok_state.pop("type"	)	)
															__lowerCamelCase		:      Any											=					add_prefix_space
															__lowerCamelCase		:      Union[str, Any]											=					pre_tok_class(**__A	)

											__lowerCamelCase		:      Any											=					add_prefix_space

											__lowerCamelCase		:      int											=					"post_processor"
											__lowerCamelCase		:      Optional[int]											=					getattr(self.backend_tokenizer			,				__A			,				__A	)
											if tokenizer_component_instance:
															__lowerCamelCase		:      Tuple											=					json.loads(tokenizer_component_instance.__getstate__()	)

															# The lists 'sep' and 'cls' must be cased in tuples for the object `post_processor_class`
															if "sep" in state:
																			__lowerCamelCase		:      Dict											=					tuple(state["sep"]	)
															if "cls" in state:
																			__lowerCamelCase		:      Union[str, Any]											=					tuple(state["cls"]	)

															__lowerCamelCase		:      Union[str, Any]											=					False

															if state.get("add_prefix_space"			,				__A	) != add_prefix_space:
																			__lowerCamelCase		:      Dict											=					add_prefix_space
																			__lowerCamelCase		:      str											=					True

															if state.get("trim_offsets"			,				__A	) != trim_offsets:
																			__lowerCamelCase		:      Tuple											=					trim_offsets
																			__lowerCamelCase		:      Optional[int]											=					True

															if changes_to_apply:
																			__lowerCamelCase		:      List[Any]											=					getattr(__A			,				state.pop("type"	)	)
																			__lowerCamelCase		:      int											=					component_class(**__A	)
																			setattr(self.backend_tokenizer			,				__A			,				__A	)







							@property
							def 		__SCREAMING_SNAKE_CASE(   self	)     ->str:



											"""simple docstring"""







											if self._mask_token is None:
															if self.verbose:
																			logger.error("Using mask_token, but it is not set yet."	)
															return None
											return str(self._mask_token	)







							@mask_token.setter
							def 		__SCREAMING_SNAKE_CASE(   self			,				__A	)     ->int:



											"""simple docstring"""







											__lowerCamelCase		:      List[Any]											=					AddedToken(__A			,				lstrip=__A			,				rstrip=__A	) if isinstance(__A			,				__A	) else value
											__lowerCamelCase		:      Optional[int]											=					value







							def 		__SCREAMING_SNAKE_CASE(   self			,				*__A			,				**__A	)     ->BatchEncoding:



											"""simple docstring"""







											__lowerCamelCase		:      Optional[int]											=					kwargs.get("is_split_into_words"			,				__A	)
											assert self.add_prefix_space or not is_split_into_words, (
											    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 		__SCREAMING_SNAKE_CASE(   self			,				*__A			,				**__A	)     ->BatchEncoding:



											"""simple docstring"""







											__lowerCamelCase		:      str											=					kwargs.get("is_split_into_words"			,				__A	)

											assert self.add_prefix_space or not is_split_into_words, (
											    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 		__SCREAMING_SNAKE_CASE(   self			,				__A			,				__A = None	)     ->Tuple[str]:



											"""simple docstring"""







											__lowerCamelCase		:      List[str]											=					self._tokenizer.model.save(__A			,				name=__A	)
											return tuple(__A	)







							def 		__SCREAMING_SNAKE_CASE(   self			,				__A			,				__A=None	)     ->Union[str, Any]:



											"""simple docstring"""







											__lowerCamelCase		:      Any											=					[self.bos_token_id] + token_ids_a + [self.eos_token_id]
											if token_ids_a is None:
															return output

											return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]







							def 		__SCREAMING_SNAKE_CASE(   self			,				__A			,				__A = None	)     ->List[int]:



											"""simple docstring"""







											__lowerCamelCase		:      List[str]											=					[self.sep_token_id]
											__lowerCamelCase		:      Tuple											=					[self.cls_token_id]

											if token_ids_a is None:
															return len(cls + token_ids_a + sep	) * [0]
											return len(cls + token_ids_a + sep + sep + token_ids_a + sep	) * [0]





