"""simple docstring"""




import os
import re
import unicodedata
from shutil import copyfile
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union

import sentencepiece as spm

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import is_torch_available, logging


if is_torch_available():
			import torch


if TYPE_CHECKING:
			from transformers.pipelines.conversational import Conversation


__lowerCAmelCase     :				Optional[Any]    				=    logging.get_logger(__name__)
__lowerCAmelCase     :				Optional[int]    				=    {"vocab_file": "spiece.model"}

__lowerCAmelCase     :				str    				=    {
    "vocab_file": {
        "AI-Sweden/gpt-sw3-126m": "https://huggingface.co/AI-Sweden/gpt-sw3-126m/resolve/main/spiece.model",
        "AI-Sweden/gpt-sw3-350m": "https://huggingface.co/AI-Sweden/gpt-sw3-350m/resolve/main/spiece.model",
        "AI-Sweden/gpt-sw3-1.6b": "https://huggingface.co/AI-Sweden/gpt-sw3-1.6b/resolve/main/spiece.model",
        "AI-Sweden/gpt-sw3-6.7b": "https://huggingface.co/AI-Sweden/gpt-sw3-6.7b/resolve/main/spiece.model",
        "AI-Sweden/gpt-sw3-20b": "https://huggingface.co/AI-Sweden/gpt-sw3-20b/resolve/main/spiece.model",
    }
}

__lowerCAmelCase     :				Optional[int]    				=    {
    "AI-Sweden/gpt-sw3-126m": 20_48,
    "AI-Sweden/gpt-sw3-350m": 20_48,
    "AI-Sweden/gpt-sw3-1.6b": 20_48,
    "AI-Sweden/gpt-sw3-6.7b": 20_48,
    "AI-Sweden/gpt-sw3-20b": 20_48,
}

class    a_   (  __UpperCamelCase      ):
					UpperCamelCase_			:						int      =     VOCAB_FILES_NAMES
					UpperCamelCase_			:						Optional[Any]      =     PRETRAINED_VOCAB_FILES_MAP
					UpperCamelCase_			:						Union[str, Any]      =     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
					UpperCamelCase_			:						List[str]      =     ["input_ids", "attention_mask"]




					def __init__(						self    :  List[str]	,    snake_case__    :  int	,    snake_case__    :  str=False	,    snake_case__    :  Optional[int]=False	,    snake_case__    :  int=False	,    snake_case__    :  str=None	,    snake_case__    :  str=None	,    snake_case__    :  Any=None	,    snake_case__    :  Optional[Any]=None	,    snake_case__    :  Optional[Dict[str, Any]] = None	,    **snake_case__    :  List[Any]	,    ):
							lowerCAmelCase__   = {} if sp_model_kwargs is None else sp_model_kwargs

							lowerCAmelCase__   = kwargs.get("""name_or_path"""  )
							if name_or_path is None:
									logger.warning(
									    """name_or_path not provided, will work for all GPTSw3 models except gpt-sw3-7b,"""
									    """ you are testing the model, this can safely be ignored"""  )
									lowerCAmelCase__   = """None"""

							# Default definitions for our 2 tokenizer versions, with None-checks to enable proper testing
							lowerCAmelCase__   = """<|endoftext|>""" if eos_token is None else eos_token
							lowerCAmelCase__   = """<unk>""" if unk_token is None else unk_token
							if "gpt-sw3-7b" in name_or_path:
									lowerCAmelCase__   = unk_token if pad_token is None else pad_token
									lowerCAmelCase__   = eos_token if bos_token is None else bos_token
							else:
									lowerCAmelCase__   = """<pad>""" if pad_token is None else pad_token
									lowerCAmelCase__   = """<s>""" if bos_token is None else bos_token

							super().__init__(
							    do_lower_case=snake_case__	,    remove_space=snake_case__	,    keep_accents=snake_case__	,    bos_token=snake_case__	,    eos_token=snake_case__	,    unk_token=snake_case__	,    pad_token=snake_case__	,    sp_model_kwargs=self.sp_model_kwargs	,    **snake_case__	,    )

							lowerCAmelCase__   = do_lower_case
							lowerCAmelCase__   = remove_space
							lowerCAmelCase__   = keep_accents
							lowerCAmelCase__   = vocab_file

							lowerCAmelCase__   = spm.SentencePieceProcessor(**self.sp_model_kwargs  )
							self.sp_model.Load(snake_case__  )

							# Used for whitespace normalization in input texts
							# fmt : off
							lowerCAmelCase__   = {""" """, """ """, """ """, """ """, """ """, """　""", """ """, """ """, """ """, """ """, """￼""", """"""}
							# fmt : on

							# Regular expression to remove non-printing characters (e.g. some unicode control chars) in preprocessing
							lowerCAmelCase__   = re.compile(
							    F"""[{''.join(map(snake_case__	,    list(range(0	,    9  )  ) + list(range(11	,    32  )  ) + list(range(127	,    160  )  ) + [160, 173, 8203]  )  )}]"""  )




					def __getstate__(						self    :  Any  ):
							lowerCAmelCase__   = self.__dict__.copy()
							lowerCAmelCase__   = None
							return state




					def __setstate__(						self    :  Union[str, Any]	,    snake_case__    :  Tuple  ):
							lowerCAmelCase__   = d

							# for backward compatibility
							if not hasattr(self	,    """sp_model_kwargs"""  ):
									lowerCAmelCase__   = {}

							lowerCAmelCase__   = spm.SentencePieceProcessor(**self.sp_model_kwargs  )
							self.sp_model.Load(self.vocab_file  )




					@property
					# Copied from transformers.models.albert.tokenization_albert.AlbertTokenizer.vocab_size
					def     _SCREAMING_SNAKE_CASE    (						self    :  int  ):
							return len(self.sp_model  )




					def     _SCREAMING_SNAKE_CASE    (						self    :  int	,    snake_case__    :  str  ):
							lowerCAmelCase__   = self.non_printing_characters_re.sub(""""""	,    snake_case__  )

							# Normalize whitespaces
							lowerCAmelCase__   = """""".join([char if char not in self.whitespaces else """ """ for char in text]  )

							# NFC Unicode normalization
							lowerCAmelCase__   = unicodedata.normalize("""NFC"""	,    snake_case__  )
							return text




					def     _SCREAMING_SNAKE_CASE    (						self    :  Any	,    snake_case__    :  str	,    **snake_case__    :  str  ):
							lowerCAmelCase__   = self.preprocess_text(snake_case__  )
							return self.sp_model.encode(snake_case__	,    out_type=snake_case__  )




					def     _SCREAMING_SNAKE_CASE    (						self    :  List[str]	,    snake_case__    :  str  ):
							return self.sp_model.PieceToId(snake_case__  )




					def     _SCREAMING_SNAKE_CASE    (						self    :  int	,    snake_case__    :  int  ):
							return self.sp_model.IdToPiece(snake_case__  )




					@staticmethod
					def     _SCREAMING_SNAKE_CASE    (						snake_case__    :  str  ):
							return out_string




					def     _SCREAMING_SNAKE_CASE    (						self    :  int	,    snake_case__    :  List[str]  ):
							lowerCAmelCase__   = []
							lowerCAmelCase__   = """"""
							lowerCAmelCase__   = False
							for token in tokens:
									# make sure that special tokens are not decoded using sentencepiece model
									if token in self.all_special_tokens:
											# TODO: Check if this is needed, as it ensures that decode(encode(doc)) != doc by adding extra whitespace in the decoded document
											if not prev_is_special:
													out_string += " "

											out_string += self.sp_model.decode(snake_case__  ) + token
											lowerCAmelCase__   = True
											lowerCAmelCase__   = []
									else:
											current_sub_tokens.append(snake_case__  )
											lowerCAmelCase__   = False
							out_string += self.sp_model.decode(snake_case__  )

							return out_string




					def     _SCREAMING_SNAKE_CASE    (						self    :  Tuple  ):
							lowerCAmelCase__   = {self.convert_ids_to_tokens(snake_case__  ): i for i in range(self.vocab_size  )}
							vocab.update(self.added_tokens_encoder  )
							return vocab




					def     _SCREAMING_SNAKE_CASE    (						self    :  Optional[Any]	,    snake_case__    :  str	,    snake_case__    :  Optional[str] = None  ):
							if not os.path.isdir(snake_case__  ):
									logger.error(F"""Vocabulary path ({save_directory}) should be a directory"""  )
									return
							lowerCAmelCase__   = os.path.join(
							    snake_case__	,    (filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]  )

							if os.path.abspath(self.vocab_file  ) != os.path.abspath(snake_case__  ) and os.path.isfile(self.vocab_file  ):
									copyfile(self.vocab_file	,    snake_case__  )
							elif not os.path.isfile(self.vocab_file  ):
									with open(snake_case__	,    """wb"""  ) as fi:
											lowerCAmelCase__   = self.sp_model.serialized_model_proto()
											fi.write(snake_case__  )

							return (out_vocab_file,)




					def     _SCREAMING_SNAKE_CASE    (						self    :  int	,    snake_case__    :  Union[str, List[str]]	,    snake_case__    :  Union[str, bool] = False  ):

							if isinstance(snake_case__	,    snake_case__  ):
									lowerCAmelCase__   = self.preprocess_text(snake_case__  )
									lowerCAmelCase__   = self.sp_model.encode(snake_case__  )
							else:
									lowerCAmelCase__   = [self.preprocess_text(snake_case__  ) for t in text]
									lowerCAmelCase__   = self.sp_model.encode(snake_case__  )

							if return_tensors is True or return_tensors == "pt":
									lowerCAmelCase__   = torch.tensor(snake_case__  )

							return token_ids




					def     _SCREAMING_SNAKE_CASE    (						self    :  str	,    snake_case__    :  Union[int, List[int]]  ):
							return self.sp_model.decode(snake_case__  )




					def     _SCREAMING_SNAKE_CASE    (						self    :  str	,    snake_case__    :  "Conversation"  ):
							lowerCAmelCase__   = [F"""User: {text}""" if is_user else F"""Bot: {text}""" for is_user, text in conversation.iter_texts()]
							lowerCAmelCase__   = (
							    F"""{self.eos_token}{self.bos_token}""" + F"""{self.bos_token}""".join(snake_case__  ) + F"""{self.bos_token}Bot:"""
							)
							return self.encode(text=snake_case__  )





"""simple docstring"""




import math
from datetime import datetime, timedelta







def 				_UpperCAmelCase		(							lowerCamelCase__  ):





		"""simple docstring"""




		lowerCAmelCase__   = year % 19
		lowerCAmelCase__   = year % 4
		lowerCAmelCase__   = year % 7
		lowerCAmelCase__   = math.floor(year / 100  )
		lowerCAmelCase__   = math.floor((13 + 8 * leap_day_inhibits) / 25  )
		lowerCAmelCase__   = leap_day_inhibits / 4
		lowerCAmelCase__   = (
		    15 - lunar_orbit_correction + leap_day_inhibits - leap_day_reinstall_number
		) % 30
		lowerCAmelCase__   = (4 + leap_day_inhibits - leap_day_reinstall_number) % 7

		# days to be added to March 21
		lowerCAmelCase__   = (19 * metonic_cycle + secular_moon_shift) % 30

		# PHM -> Paschal Full Moon
		lowerCAmelCase__   = (
		    2 * julian_leap_year
		    + 4 * non_leap_year
		    + 6 * days_to_add
		    + century_starting_point
		) % 7

		if days_to_add == 29 and days_from_phm_to_sunday == 6:
				return datetime(lowerCamelCase__      ,	4      ,	19  )
		elif days_to_add == 28 and days_from_phm_to_sunday == 6:
				return datetime(lowerCamelCase__      ,	4      ,	18  )
		else:
				return datetime(lowerCamelCase__      ,	3      ,	22  ) + timedelta(
				    days=int(days_to_add + days_from_phm_to_sunday  )  )


if __name__ == "__main__":
			for year in (19_94, 20_00, 20_10, 20_21, 20_23):
						__lowerCAmelCase     :				List[str]    				=    "will be" if year > datetime.now().year else "was"
						print(F"Easter in {year} {tense} {gauss_easter(year)}")




