code: 
  
  
  from typing import Dict, List, Optional, Tuple
  
  from ...tokenization_utils import AddedToken, PreTrainedTokenizer
  from ...utils import logging
  
  
  SCREAMING_SNAKE_CASE : Optional[Any]          =    logging.get_logger(__name__)
  
  
  
  
  
  class 					snake_case__    ( A_       ):
  	UpperCAmelCase   :							Any         = ['''input_ids''', '''attention_mask''']
  
  
  
  
  
  	def __init__(  self				,    UpperCamelCase_="[PAD]"				,    UpperCamelCase_="[BOS]"				,    UpperCamelCase_="[EOS]"				,    UpperCamelCase_="[MASK]"				,    UpperCamelCase_="[CLS]"				,    UpperCamelCase_="[SEP]"				,    UpperCamelCase_=2048				,    **UpperCamelCase_				,    )		->			Union[str, Any]:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Dict			=	AddedToken(UpperCamelCase_				,    lstrip=UpperCamelCase_				,    rstrip=UpperCamelCase_							) if isinstance(UpperCamelCase_				,    UpperCamelCase_							) else pad_token
  								a_       :   Dict			=	AddedToken(UpperCamelCase_				,    lstrip=UpperCamelCase_				,    rstrip=UpperCamelCase_							) if isinstance(UpperCamelCase_				,    UpperCamelCase_							) else bos_token
  								a_       :   Tuple			=	AddedToken(UpperCamelCase_				,    lstrip=UpperCamelCase_				,    rstrip=UpperCamelCase_							) if isinstance(UpperCamelCase_				,    UpperCamelCase_							) else eos_token
  								a_       :   Any			=	AddedToken(UpperCamelCase_				,    lstrip=UpperCamelCase_				,    rstrip=UpperCamelCase_							) if isinstance(UpperCamelCase_				,    UpperCamelCase_							) else mask_token
  								a_       :   List[str]			=	AddedToken(UpperCamelCase_				,    lstrip=UpperCamelCase_				,    rstrip=UpperCamelCase_							) if isinstance(UpperCamelCase_				,    UpperCamelCase_							) else cls_token
  								a_       :   Tuple			=	AddedToken(UpperCamelCase_				,    lstrip=UpperCamelCase_				,    rstrip=UpperCamelCase_							) if isinstance(UpperCamelCase_				,    UpperCamelCase_							) else sep_token
  
  								super().__init__(
  								    pad_token=UpperCamelCase_				,    bos_token=UpperCamelCase_				,    eos_token=UpperCamelCase_				,    mask_token=UpperCamelCase_				,    cls_token=UpperCamelCase_				,    sep_token=UpperCamelCase_				,    model_max_length=UpperCamelCase_				,    **UpperCamelCase_				,    )
  
  								a_       :   Any			=	2**8  # utf is 8 bits
  
  								# define special tokens dict
  								a_       :   List[str]			=	{
  								    self.pad_token: 0,
  								    self.bos_token: 1,
  								    self.eos_token: 2,
  								    self.mask_token: 3,
  								    self.cls_token: 4,
  								    self.sep_token: 5,
  								}
  								a_       :   Any			=	len(self.special_tokens_encoder							)
  								a_       :   Union[str, Any]			=	{v: k for k, v in self.special_tokens_encoder.items()}
  
  
  
  
  
  	def     A				(  self							)		->			Dict:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Dict			=	self.special_tokens_encoder.copy()
  								vocab.update(self.added_tokens_encoder							)
  								for i in range(self._utf_vocab_size							):
  															a_       :   Any			=	chr(UpperCamelCase_							)
  															a_       :   List[Any]			=	i + len(self.special_tokens_encoder							)
  								return vocab
  
  
  
  
  
  	@property
  	def     A				(  self							)		->			List[str]:
  								"""simple docstring"""
  
  
  
  
  
  
  								return self._utf_vocab_size + self._num_special_tokens
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_				,    UpperCamelCase_ = None				,    UpperCamelCase_ = False							)		->			Any:
  								"""simple docstring"""
  
  
  
  
  
  
  								if already_has_special_tokens:
  															return super().get_special_tokens_mask(
  															    token_ids_a=UpperCamelCase_				,    token_ids_a=UpperCamelCase_				,    already_has_special_tokens=UpperCamelCase_							)
  
  								# normal case: some special tokens
  								if token_ids_a is None:
  															return [1] + [0] * len(UpperCamelCase_							) + [1]
  								return [1] + ([0] * len(UpperCamelCase_							)) + [1] + ([0] * len(UpperCamelCase_							)) + [1]
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_				,    UpperCamelCase_ = None							)		->			Optional[Any]:
  								"""simple docstring"""
  
  
  
  
  
  
  								if token_ids_a is None:
  															return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
  								else:
  															return [self.cls_token_id] + token_ids_a + [self.sep_token_id] + token_ids_a + [self.sep_token_id]
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_							)		->			str:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Union[str, Any]			=	[chr(UpperCamelCase_							) for i in text.encode("""utf-8"""							)]
  								return tokens
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_							)		->			List[str]:
  								"""simple docstring"""
  
  
  
  
  
  
  								if token in self.special_tokens_encoder:
  															a_       :   Union[str, Any]			=	self.special_tokens_encoder[token]
  								elif token in self.added_tokens_encoder:
  															a_       :   Optional[Any]			=	self.added_tokens_encoder[token]
  								elif len(UpperCamelCase_							) != 1:
  															a_       :   Tuple			=	self.unk_token_id
  								else:
  															a_       :   Tuple			=	ord(UpperCamelCase_							) + self._num_special_tokens
  								return token_id
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_							)		->			Tuple:
  								"""simple docstring"""
  
  
  
  
  
  
  								if index in self.special_tokens_decoder:
  															a_       :   List[str]			=	self.special_tokens_decoder[index]
  								elif index in self.added_tokens_decoder:
  															a_       :   str			=	self.added_tokens_decoder[index]
  								else:
  															a_       :   Optional[int]			=	chr(index - self._num_special_tokens							)
  								return token
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_							)		->			int:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Optional[int]			=	B""""""
  								for token in tokens:
  															if token in self.special_tokens_decoder:
  																						a_       :   Dict			=	self.special_tokens_decoder[token].encode("""utf-8"""							)
  															elif token in self.added_tokens_decoder:
  																						a_       :   List[Any]			=	self.special_tokens_decoder[token].encode("""utf-8"""							)
  															elif token in self.special_tokens_encoder:
  																						a_       :   Dict			=	token.encode("""utf-8"""							)
  															elif token in self.added_tokens_encoder:
  																						a_       :   Optional[Any]			=	token.encode("""utf-8"""							)
  															else:
  																						a_       :   Optional[Any]			=	bytes([ord(UpperCamelCase_							)]							)
  															bstring += tok_string
  								a_       :   Any			=	bstring.decode("""utf-8"""				,    errors="""replace"""							)
  								return string
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_				,    UpperCamelCase_ = None							)		->			int:
  								"""simple docstring"""
  
  
  
  
  
  
  								return ()
  
  
  
style_context: 
  
  
  from ...utils import is_transformers_available
  from .pipeline_latent_diffusion_superresolution import LDMSuperResolutionPipeline
  
  
  if is_transformers_available():
  	from .pipeline_latent_diffusion import LDMBertModel, LDMTextToImagePipeline
  
  
  