



import copy
import random

from transformers import CLIPTokenizer

class   _A   ( lowercase__	):


						'''simple docstring'''





						def __init__(	self	:							Optional[int]							,      *lowerCamelCase	:							Optional[Any]							,      **lowerCamelCase	:							str	):






							'''simple docstring'''



							super().__init__(*__lowercase							,      **__lowercase	)
							__lowercase		       =			{}



						def     _snake_case	(	self	:							Union[str, Any]							,      lowerCamelCase	:							int							,      *lowerCamelCase	:							List[str]							,      **lowerCamelCase	:							Dict	):






							'''simple docstring'''



							__lowercase		       =			super().add_tokens(__lowercase							,      *__lowercase							,      **__lowercase	)
							if num_added_tokens == 0:
								raise ValueError(
								    f"""The tokenizer already contains the token {placeholder_token}. Please pass a different"""
								    " `placeholder_token` that is not already in the tokenizer."	)



						def     _snake_case	(	self	:							Dict							,      lowerCamelCase	:							List[Any]							,      *lowerCamelCase	:							List[Any]							,      lowerCamelCase	:							str=1							,      **lowerCamelCase	:							int	):






							'''simple docstring'''



							__lowercase		       =			[]
							if num_vec_per_token == 1:
								self.try_adding_tokens(__lowercase							,      *__lowercase							,      **__lowercase	)
								output.append(__lowercase	)
							else:
								__lowercase		       =			[]
								for i in range(__lowercase	):
									__lowercase		       =			placeholder_token + f"""_{i}"""
									self.try_adding_tokens(__lowercase							,      *__lowercase							,      **__lowercase	)
									output.append(__lowercase	)
        # handle cases where there is a new placeholder token that contains the current placeholder token but is larger
							for token in self.token_map:
								if token in placeholder_token:
									raise ValueError(
									    f"""The tokenizer already has placeholder token {token} that can get confused with"""
									    f""" {placeholder_token}keep placeholder tokens independent"""	)
							__lowercase		       =			output



						def     _snake_case	(	self	:							Optional[int]							,      lowerCamelCase	:							Optional[Any]							,      lowerCamelCase	:							str=False							,      lowerCamelCase	:							Dict=1.0	):






							'''simple docstring'''



							if isinstance(__lowercase							,      __lowercase	):
								__lowercase		       =			[]
								for i in range(len(__lowercase	)	):
									output.append(self.replace_placeholder_tokens_in_text(text[i]							,      vector_shuffle=__lowercase	)	)
								return output
							for placeholder_token in self.token_map:
								if placeholder_token in text:
									__lowercase		       =			self.token_map[placeholder_token]
									__lowercase		       =			tokens[: 1 + int(len(__lowercase	) * prop_tokens_to_load	)]
									if vector_shuffle:
										__lowercase		       =			copy.copy(__lowercase	)
										random.shuffle(__lowercase	)
									__lowercase		       =			text.replace(__lowercase							,      " ".join(__lowercase	)	)
							return text



						def __call__(	self	:							Optional[int]							,      lowerCamelCase	:							Tuple							,      *lowerCamelCase	:							Dict							,      lowerCamelCase	:							Any=False							,      lowerCamelCase	:							Optional[int]=1.0							,      **lowerCamelCase	:							Tuple	):






							'''simple docstring'''



							return super().__call__(
							    self.replace_placeholder_tokens_in_text(
							        __lowercase							,      vector_shuffle=__lowercase							,      prop_tokens_to_load=__lowercase	)							,      *__lowercase							,      **__lowercase							,      )



						def     _snake_case	(	self	:							Optional[Any]							,      lowerCamelCase	:							Any							,      *lowerCamelCase	:							Union[str, Any]							,      lowerCamelCase	:							int=False							,      lowerCamelCase	:							Optional[int]=1.0							,      **lowerCamelCase	:							Any	):






							'''simple docstring'''



							return super().encode(
							    self.replace_placeholder_tokens_in_text(
							        __lowercase							,      vector_shuffle=__lowercase							,      prop_tokens_to_load=__lowercase	)							,      *__lowercase							,      **__lowercase							,      )








import os
import sys
from contextlib import contextmanager


# Windows only
if os.name == "nt":
	import ctypes
	import msvcrt  # noqa

	class   _A   ( ctypes.Structure	):


							'''simple docstring'''





							_snake_case			:     Optional[Any]      							=      [("""size""", ctypes.c_int), ("""visible""", ctypes.c_byte)]



def    snake_case_				(    ):
	if os.name == "nt":
		__lowercase		       =			CursorInfo()
		__lowercase		       =			ctypes.windll.kernelaa.GetStdHandle(-1_1   )
		ctypes.windll.kernelaa.GetConsoleCursorInfo(_SCREAMING_SNAKE_CASE  ,	ctypes.byref(_SCREAMING_SNAKE_CASE   )   )
		__lowercase		       =			False
		ctypes.windll.kernelaa.SetConsoleCursorInfo(_SCREAMING_SNAKE_CASE  ,	ctypes.byref(_SCREAMING_SNAKE_CASE   )   )
	elif os.name == "posix":
		sys.stdout.write("\033[?25l"   )
		sys.stdout.flush()



def    snake_case_				(    ):
	if os.name == "nt":
		__lowercase		       =			CursorInfo()
		__lowercase		       =			ctypes.windll.kernelaa.GetStdHandle(-1_1   )
		ctypes.windll.kernelaa.GetConsoleCursorInfo(_SCREAMING_SNAKE_CASE  ,	ctypes.byref(_SCREAMING_SNAKE_CASE   )   )
		__lowercase		       =			True
		ctypes.windll.kernelaa.SetConsoleCursorInfo(_SCREAMING_SNAKE_CASE  ,	ctypes.byref(_SCREAMING_SNAKE_CASE   )   )
	elif os.name == "posix":
		sys.stdout.write("\033[?25h"   )
		sys.stdout.flush()



@contextmanager
def    snake_case_				(    ):
	try:
		hide_cursor()
		yield
	finally:
		show_cursor()



