



import json
import os
from functools import lru_cache
from typing import TYPE_CHECKING, List, Optional, Tuple

import regex as re

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


if TYPE_CHECKING:
						from transformers.pipelines.conversational import Conversation

UpperCAmelCase_			      =  logging.get_logger(__name__)

UpperCAmelCase_			      =  {
    'vocab_file': 'vocab.json',
    'merges_file': 'merges.txt',
}

UpperCAmelCase_			      =  {
    'vocab_file': {
        'gpt2': 'https://huggingface.co/gpt2/resolve/main/vocab.json',
        'gpt2-medium': 'https://huggingface.co/gpt2-medium/resolve/main/vocab.json',
        'gpt2-large': 'https://huggingface.co/gpt2-large/resolve/main/vocab.json',
        'gpt2-xl': 'https://huggingface.co/gpt2-xl/resolve/main/vocab.json',
        'distilgpt2': 'https://huggingface.co/distilgpt2/resolve/main/vocab.json',
    },
    'merges_file': {
        'gpt2': 'https://huggingface.co/gpt2/resolve/main/merges.txt',
        'gpt2-medium': 'https://huggingface.co/gpt2-medium/resolve/main/merges.txt',
        'gpt2-large': 'https://huggingface.co/gpt2-large/resolve/main/merges.txt',
        'gpt2-xl': 'https://huggingface.co/gpt2-xl/resolve/main/merges.txt',
        'distilgpt2': 'https://huggingface.co/distilgpt2/resolve/main/merges.txt',
    },
}

UpperCAmelCase_			      =  {
    'gpt2': 1_024,
    'gpt2-medium': 1_024,
    'gpt2-large': 1_024,
    'gpt2-xl': 1_024,
    'distilgpt2': 1_024,
}
@lru_cache()
def   UpperCAmelCase							(		)							->					str:
	_snake_case					:							Tuple					     =   (
	    list(range(ord("""!"""     )				,  ord("""~"""     ) + 1     )     ) + list(range(ord("""¡"""     )				,  ord("""¬"""     ) + 1     )     ) + list(range(ord("""®"""     )				,  ord("""ÿ"""     ) + 1     )     )
	)
	_snake_case					:							Union[str, Any]					     =   bs[:]
	_snake_case					:							Union[str, Any]					     =   0
	for b in range(2**8     ):
		if b not in bs:
			bs.append(__UpperCamelCase     )
			cs.append(2**8 + n     )
			n += 1
	_snake_case					:							int					     =   [chr(__UpperCamelCase     ) for n in cs]
	return dict(zip(__UpperCamelCase				,  __UpperCamelCase     )     )
def   UpperCAmelCase							(		A__     )							->					Optional[int]:
	_snake_case					:							Optional[Any]					     =   set()
	_snake_case					:							Union[str, Any]					     =   word[0]
	for char in word[1:]:
		pairs.add((prev_char, char)     )
		_snake_case					:							Dict					     =   char
	return pairs





class 		__SCREAMING_SNAKE_CASE      (				SCREAMING_SNAKE_CASE_      ):






				"""simple docstring"""

				SCREAMING_SNAKE_CASE_ 				=  VOCAB_FILES_NAMES
				SCREAMING_SNAKE_CASE_ 				=  PRETRAINED_VOCAB_FILES_MAP
				SCREAMING_SNAKE_CASE_ 				=  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
				SCREAMING_SNAKE_CASE_ 				=  ['input_ids', 'attention_mask']







				def __init__(				self						,	SCREAMING_SNAKE_CASE__						,	SCREAMING_SNAKE_CASE__						,	SCREAMING_SNAKE_CASE__="replace"						,	SCREAMING_SNAKE_CASE__="<|endoftext|>"						,	SCREAMING_SNAKE_CASE__="<|endoftext|>"						,	SCREAMING_SNAKE_CASE__="<|endoftext|>"						,	SCREAMING_SNAKE_CASE__=None						,	SCREAMING_SNAKE_CASE__=False						,	SCREAMING_SNAKE_CASE__=False						,	**SCREAMING_SNAKE_CASE__						,	):






					"""simple docstring"""

					_snake_case					:							Tuple					     =   AddedToken(UpperCamelCase__						,	lstrip=UpperCamelCase__						,	rstrip=UpperCamelCase__      ) if isinstance(UpperCamelCase__						,	UpperCamelCase__      ) else bos_token
					_snake_case					:							List[Any]					     =   AddedToken(UpperCamelCase__						,	lstrip=UpperCamelCase__						,	rstrip=UpperCamelCase__      ) if isinstance(UpperCamelCase__						,	UpperCamelCase__      ) else eos_token
					_snake_case					:							str					     =   AddedToken(UpperCamelCase__						,	lstrip=UpperCamelCase__						,	rstrip=UpperCamelCase__      ) if isinstance(UpperCamelCase__						,	UpperCamelCase__      ) else unk_token
					_snake_case					:							Optional[int]					     =   AddedToken(UpperCamelCase__						,	lstrip=UpperCamelCase__						,	rstrip=UpperCamelCase__      ) if isinstance(UpperCamelCase__						,	UpperCamelCase__      ) else pad_token
					super().__init__(
					    errors=UpperCamelCase__						,	unk_token=UpperCamelCase__						,	bos_token=UpperCamelCase__						,	eos_token=UpperCamelCase__						,	pad_token=UpperCamelCase__						,	add_prefix_space=UpperCamelCase__						,	add_bos_token=UpperCamelCase__						,	**UpperCamelCase__						,	)
					_snake_case					:							List[Any]					     =   add_bos_token

					with open(UpperCamelCase__						,	encoding="""utf-8"""      ) as vocab_handle:
						_snake_case					:							str					     =   json.load(UpperCamelCase__      )
					_snake_case					:							Dict					     =   {v: k for k, v in self.encoder.items()}
					_snake_case					:							List[Any]					     =   errors  # how to handle errors in decoding
					_snake_case					:							Dict					     =   bytes_to_unicode()
					_snake_case					:							List[Any]					     =   {v: k for k, v in self.byte_encoder.items()}
					with open(UpperCamelCase__						,	encoding="""utf-8"""      ) as merges_handle:
						_snake_case					:							List[str]					     =   merges_handle.read().split("""\n"""      )[1:-1]
					_snake_case					:							Optional[Any]					     =   [tuple(merge.split()      ) for merge in bpe_merges]
					_snake_case					:							List[str]					     =   dict(zip(UpperCamelCase__						,	range(len(UpperCamelCase__      )      )      )      )
					_snake_case					:							Optional[int]					     =   {}
					_snake_case					:							int					     =   add_prefix_space

					# Should have added re.IGNORECASE so BPE merges can happen for capitalized versions of contractions
					_snake_case					:							Optional[int]					     =   re.compile(r"""\'s|\'t|\'re|\'ve|\'m|\'ll|\'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+"""      )







				@property
				def 		__lowerCamelCase(				self      ):






					"""simple docstring"""

					return len(self.encoder      )







				def 		__lowerCamelCase(				self      ):






					"""simple docstring"""

					return dict(self.encoder						,	**self.added_tokens_encoder      )







				def 		__lowerCamelCase(				self						,	SCREAMING_SNAKE_CASE__      ):






					"""simple docstring"""

					if token in self.cache:
						return self.cache[token]
					_snake_case					:							Any					     =   tuple(UpperCamelCase__      )
					_snake_case					:							List[str]					     =   get_pairs(UpperCamelCase__      )

					if not pairs:
						return token

					while True:
						_snake_case					:							Dict					     =   min(UpperCamelCase__						,	key=lambda SCREAMING_SNAKE_CASE__      : self.bpe_ranks.get(UpperCamelCase__						,	float("""inf"""      )      )      )
						if bigram not in self.bpe_ranks:
							break
						_snake_case					:							List[str]					     =   bigram
						_snake_case					:							Optional[int]					     =   []
						_snake_case					:							Union[str, Any]					     =   0
						while i < len(UpperCamelCase__      ):
							try:
								_snake_case					:							List[Any]					     =   word.index(UpperCamelCase__						,	UpperCamelCase__      )
							except ValueError:
								new_word.extend(word[i:]      )
								break
							else:
								new_word.extend(word[i:j]      )
								_snake_case					:							Any					     =   j

							if word[i] == first and i < len(UpperCamelCase__      ) - 1 and word[i + 1] == second:
								new_word.append(first + second      )
								i += 2
							else:
								new_word.append(word[i]      )
								i += 1
						_snake_case					:							List[str]					     =   tuple(UpperCamelCase__      )
						_snake_case					:							Optional[Any]					     =   new_word
						if len(UpperCamelCase__      ) == 1:
							break
						else:
							_snake_case					:							Optional[int]					     =   get_pairs(UpperCamelCase__      )
					_snake_case					:							int					     =   ''' '''.join(UpperCamelCase__      )
					_snake_case					:							List[str]					     =   word
					return word







				def 		__lowerCamelCase(				self						,	SCREAMING_SNAKE_CASE__						,	SCREAMING_SNAKE_CASE__=None      ):






					"""simple docstring"""

					if self.add_bos_token:
						_snake_case					:							Union[str, Any]					     =   [self.bos_token_id]
					else:
						_snake_case					:							int					     =   []

					_snake_case					:							str					     =   bos_token_ids + token_ids_a

					if token_ids_a is None:
						return output

					return output + bos_token_ids + token_ids_a







				def 		__lowerCamelCase(				self						,	SCREAMING_SNAKE_CASE__						,	SCREAMING_SNAKE_CASE__ = None						,	SCREAMING_SNAKE_CASE__ = False      ):






					"""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__      )

					if not self.add_bos_token:
						return super().get_special_tokens_mask(
						    token_ids_a=UpperCamelCase__						,	token_ids_a=UpperCamelCase__						,	already_has_special_tokens=UpperCamelCase__      )

					if token_ids_a is None:
						return [1] + ([0] * len(UpperCamelCase__      ))
					return [1] + ([0] * len(UpperCamelCase__      )) + [1] + ([0] * len(UpperCamelCase__      ))







				def 		__lowerCamelCase(				self						,	SCREAMING_SNAKE_CASE__      ):






					"""simple docstring"""

					_snake_case					:							str					     =   []
					for token in re.findall(self.pat						,	UpperCamelCase__      ):
						_snake_case					:							Dict					     =   ''''''.join(
						    self.byte_encoder[b] for b in token.encode("""utf-8"""      )      )  # Maps all our bytes to unicode strings, avoiding control tokens of the BPE (spaces in our case)
						bpe_tokens.extend(bpe_token for bpe_token in self.bpe(UpperCamelCase__      ).split(""" """      )      )
					return bpe_tokens







				def 		__lowerCamelCase(				self						,	SCREAMING_SNAKE_CASE__      ):






					"""simple docstring"""

					return self.encoder.get(UpperCamelCase__						,	self.encoder.get(self.unk_token      )      )







				def 		__lowerCamelCase(				self						,	SCREAMING_SNAKE_CASE__      ):






					"""simple docstring"""

					return self.decoder.get(UpperCamelCase__      )







				def 		__lowerCamelCase(				self						,	SCREAMING_SNAKE_CASE__      ):






					"""simple docstring"""

					_snake_case					:							List[Any]					     =   ''''''.join(UpperCamelCase__      )
					_snake_case					:							Union[str, Any]					     =   bytearray([self.byte_decoder[c] for c in text]      ).decode("""utf-8"""						,	errors=self.errors      )
					return text







				def 		__lowerCamelCase(				self						,	SCREAMING_SNAKE_CASE__						,	SCREAMING_SNAKE_CASE__ = None      ):






					"""simple docstring"""

					if not os.path.isdir(UpperCamelCase__      ):
						logger.error(f'''Vocabulary path ({save_directory}) should be a directory'''      )
						return
					_snake_case					:							Optional[Any]					     =   os.path.join(
					    UpperCamelCase__						,	(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]      )
					_snake_case					:							Any					     =   os.path.join(
					    UpperCamelCase__						,	(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""merges_file"""]      )

					with open(UpperCamelCase__						,	"""w"""						,	encoding="""utf-8"""      ) as f:
						f.write(json.dumps(self.encoder						,	indent=2						,	sort_keys=UpperCamelCase__						,	ensure_ascii=UpperCamelCase__      ) + """\n"""      )

					_snake_case					:							Any					     =   0
					with open(UpperCamelCase__						,	"""w"""						,	encoding="""utf-8"""      ) as writer:
						writer.write("""#version: 0.2\n"""      )
						for bpe_tokens, token_index in sorted(self.bpe_ranks.items()						,	key=lambda SCREAMING_SNAKE_CASE__      : kv[1]      ):
							if index != token_index:
								logger.warning(
								    f'''Saving vocabulary to {merge_file}: BPE merge indices are not consecutive.'''
								    """ Please check that the tokenizer is not corrupted!"""      )
								_snake_case					:							Union[str, Any]					     =   token_index
							writer.write(""" """.join(UpperCamelCase__      ) + """\n"""      )
							index += 1

					return vocab_file, merge_file







				def 		__lowerCamelCase(				self						,	SCREAMING_SNAKE_CASE__						,	SCREAMING_SNAKE_CASE__=False						,	**SCREAMING_SNAKE_CASE__      ):






					"""simple docstring"""

					_snake_case					:							int					     =   kwargs.pop("""add_prefix_space"""						,	self.add_prefix_space      )
					if is_split_into_words or add_prefix_space:
						_snake_case					:							List[str]					     =   ''' ''' + text
					return (text, kwargs)







				def 		__lowerCamelCase(				self						,	SCREAMING_SNAKE_CASE__      ):






					"""simple docstring"""

					_snake_case					:							Dict					     =   []
					for is_user, text in conversation.iter_texts():
						input_ids.extend(self.encode(UpperCamelCase__						,	add_special_tokens=UpperCamelCase__      ) + [self.eos_token_id]      )
					if len(UpperCamelCase__      ) > self.model_max_length:
						_snake_case					:							Union[str, Any]					     =   input_ids[-self.model_max_length :]
					return input_ids







import unittest

from transformers.testing_utils import is_torch_available, require_torch, tooslow

from ...generation.test_utils import torch_device
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
					import torch

					from transformers import (
					    CpmAntConfig,
					    CpmAntForCausalLM,
					    CpmAntModel,
					    CpmAntTokenizer,
					)







@require_torch
class 			UpperCamelCase__		:







	'''simple docstring'''





	def __init__(      self					,							UpperCamelCase__					,							UpperCamelCase__=2					,							UpperCamelCase__=8					,							UpperCamelCase__=True					,							UpperCamelCase__=False					,							UpperCamelCase__=False					,							UpperCamelCase__=False					,							UpperCamelCase__=False					,							UpperCamelCase__=99					,							UpperCamelCase__=32					,							UpperCamelCase__=3					,							UpperCamelCase__=4					,							UpperCamelCase__=37					,							UpperCamelCase__=32					,							UpperCamelCase__=128					,							UpperCamelCase__=8					,							UpperCamelCase__=8					,							UpperCamelCase__=8					,							UpperCamelCase__=1.0					,							UpperCamelCase__=True					,							):
					A__	:						Dict								=				parent
					A__	:						Optional[int]								=				batch_size
					A__	:						Any								=				seq_length
					A__	:						Tuple								=				is_training
					A__	:						List[str]								=				use_token_type_ids
					A__	:						List[Any]								=				use_input_mask
					A__	:						Any								=				use_labels
					A__	:						Dict								=				use_mc_token_ids
					A__	:						Tuple								=				vocab_size
					A__	:						Any								=				hidden_size
					A__	:						List[Any]								=				num_hidden_layers
					A__	:						Union[str, Any]								=				num_attention_heads
					A__	:						Tuple								=				intermediate_size
					A__	:						Union[str, Any]								=				num_buckets
					A__	:						Dict								=				max_distance
					A__	:						str								=				prompt_length
					A__	:						int								=				prompt_types
					A__	:						int								=				segment_types
					A__	:						Union[str, Any]								=				init_std
					A__	:						Dict								=				return_dict





	def 	__snake_case					(      self		):
					A__	:						Optional[int]								=				{}
					A__	:						List[Any]								=				ids_tensor([self.batch_size, self.seq_length]					,							self.vocab_size		).type(torch.intaa		)
					A__	:						Dict								=				False

					A__	:						Union[str, Any]								=				self.get_config()

					return (config, input_ids)





	def 	__snake_case					(      self		):
					return CpmAntConfig(
					    vocab_size=self.vocab_size					,							hidden_size=self.hidden_size					,							num_hidden_layers=self.num_hidden_layers					,							num_attention_heads=self.num_attention_heads					,							dim_ff=self.intermediate_size					,							position_bias_num_buckets=self.num_buckets					,							position_bias_max_distance=self.max_distance					,							prompt_types=self.prompt_types					,							prompt_length=self.prompt_length					,							segment_types=self.segment_types					,							use_cache=UpperCamelCase__					,							init_std=self.init_std					,							return_dict=self.return_dict					,							)





	def 	__snake_case					(      self					,							UpperCamelCase__					,							UpperCamelCase__					,							*UpperCamelCase__		):
					A__	:						Tuple								=				CpmAntModel(config=UpperCamelCase__		)
					model.to(UpperCamelCase__		)
					model.eval()

					A__	:						Union[str, Any]								=				model(**UpperCamelCase__		).last_hidden_state

					self.parent.assertEqual(hidden_states.shape					,							(self.batch_size, self.seq_length, config.hidden_size)		)





	def 	__snake_case					(      self					,							UpperCamelCase__					,							UpperCamelCase__					,							*UpperCamelCase__		):
					A__	:						int								=				CpmAntForCausalLM(UpperCamelCase__		)
					model.to(UpperCamelCase__		)
					A__	:						Any								=				input_ids['''input_ids'''].to(UpperCamelCase__		)
					model.eval()

					A__	:						Dict								=				model(**UpperCamelCase__		)
					self.parent.assertEqual(
					    model_output.logits.shape					,							(self.batch_size, self.seq_length, config.vocab_size + config.prompt_types * config.prompt_length)					,							)





	def 	__snake_case					(      self		):
					A__							,				A__	:						List[str]								=				self.prepare_config_and_inputs()
					return config, inputs_dict







@require_torch
class 			UpperCamelCase__		(     SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_,      unittest.TestCase ):







	'''simple docstring'''
	_lowerCAmelCase											=					(CpmAntModel, CpmAntForCausalLM) if is_torch_available() else ()
	_lowerCAmelCase											=					(
	    {"feature-extraction": CpmAntModel, "text-generation": CpmAntForCausalLM} if is_torch_available() else {}
	)

	_lowerCAmelCase											=					False
	_lowerCAmelCase											=					False
	_lowerCAmelCase											=					False
	_lowerCAmelCase											=					False
	_lowerCAmelCase											=					False





	def 	__snake_case					(      self		):
					A__	:						Optional[int]								=				CpmAntModelTester(self		)
					A__	:						List[str]								=				ConfigTester(self					,							config_class=UpperCamelCase__		)





	def 	__snake_case					(      self		):
					self.config_tester.create_and_test_config_common_properties()
					self.config_tester.create_and_test_config_to_json_string()
					self.config_tester.create_and_test_config_to_json_file()
					self.config_tester.create_and_test_config_from_and_save_pretrained()
					self.config_tester.check_config_can_be_init_without_params()
					self.config_tester.check_config_arguments_init()





	def 	__snake_case					(      self		):
					unittest.skip('''CPMAnt doesn\'t support input_embeds.'''		)(self.test_inputs_embeds		)





	def 	__snake_case					(      self		):
					unittest.skip(
					    '''CPMAnt doesn\'t support retain grad in hidden_states or attentions, because prompt management will peel off the output.hidden_states from graph.\
                 So is attentions. We strongly recommand you use loss to tune model.'''		)(self.test_retain_grad_hidden_states_attentions		)





	def 	__snake_case					(      self		):
					A__							,				A__	:						Tuple								=				self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_cpmant_model(UpperCamelCase__					,							UpperCamelCase__		)





	def 	__snake_case					(      self		):
					A__							,				A__	:						List[str]								=				self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_lm_head_model(UpperCamelCase__					,							UpperCamelCase__		)







@require_torch
class 			UpperCamelCase__		(     unittest.TestCase ):







	'''simple docstring'''





	@tooslow
	def 	__snake_case					(      self		):
					A__	:						Optional[int]								=				'''今天天气真好！'''
					A__	:						Any								=				'''openbmb/cpm-ant-10b'''
					A__	:						Tuple								=				CpmAntModel.from_pretrained(UpperCamelCase__		)
					A__	:						str								=				CpmAntTokenizer.from_pretrained(UpperCamelCase__		)
					A__	:						Union[str, Any]								=				tokenizer(UpperCamelCase__					,							return_tensors='''pt'''		)
					A__	:						Tuple								=				model(**UpperCamelCase__		).last_hidden_state

					A__	:						str								=				torch.tensor(
					    [[[6.1_7_0_8, 5.9_2_4_4, 1.0_8_3_5], [6.5_2_0_7, 6.2_8_9_3, -1_1.3_3_2_4], [-1.0_1_0_7, -0.0_5_7_6, -5.9_5_7_7]]]					,							)
					self.assertTrue(torch.allclose(hidden_states[:, :3, :3]					,							UpperCamelCase__					,							atol=1e-2		)		)







@require_torch
class 			UpperCamelCase__		(     unittest.TestCase ):







	'''simple docstring'''





	@tooslow
	def 	__snake_case					(      self		):
					A__	:						Union[str, Any]								=				'''今天天气真好！'''
					A__	:						List[str]								=				'''openbmb/cpm-ant-10b'''
					A__	:						Tuple								=				CpmAntForCausalLM.from_pretrained(UpperCamelCase__		)
					A__	:						Tuple								=				CpmAntTokenizer.from_pretrained(UpperCamelCase__		)
					A__	:						Union[str, Any]								=				tokenizer(UpperCamelCase__					,							return_tensors='''pt'''		)
					A__	:						Optional[Any]								=				model(**UpperCamelCase__		).logits

					A__	:						List[str]								=				torch.tensor(
					    [[[-6.4_2_6_7, -6.4_0_8_3, -6.3_9_5_8], [-5.8_8_0_2, -5.9_4_4_7, -5.7_8_1_1], [-5.3_8_9_6, -5.4_8_2_0, -5.4_2_9_5]]]					,							)
					self.assertTrue(torch.allclose(hidden_states[:, :3, :3]					,							UpperCamelCase__					,							atol=1e-2		)		)





	@tooslow
	def 	__snake_case					(      self		):
					A__	:						Tuple								=				'''openbmb/cpm-ant-10b'''
					A__	:						Tuple								=				CpmAntForCausalLM.from_pretrained(UpperCamelCase__		)
					A__	:						Optional[Any]								=				CpmAntTokenizer.from_pretrained(UpperCamelCase__		)
					A__	:						int								=				'''今天天气不错，'''
					A__	:						Dict								=				'''今天天气不错，阳光明媚，我和妈妈一起去超市买东西。\n在超市里，我看到了一个很好玩的玩具，它的名字叫“机器人”。它有一个圆圆的脑袋，两只圆圆的眼睛，还有一个圆圆的'''
					A__	:						Dict								=				tokenizer(UpperCamelCase__					,							return_tensors='''pt'''		)
					A__	:						Any								=				model.generate(**UpperCamelCase__		)
					A__	:						List[str]								=				tokenizer.batch_decode(UpperCamelCase__		)
					self.assertEqual(UpperCamelCase__					,							UpperCamelCase__		)





	@tooslow
	def 	__snake_case					(      self		):
					A__	:						Optional[int]								=				'''openbmb/cpm-ant-10b'''
					A__	:						Tuple								=				CpmAntForCausalLM.from_pretrained(UpperCamelCase__		)
					A__	:						List[Any]								=				CpmAntTokenizer.from_pretrained(UpperCamelCase__		)
					A__	:						Optional[Any]								=				['''今天天气不错，''', '''新年快乐，万事如意！''']
					A__	:						Any								=				[
					    '''今天天气不错，阳光明媚，我和妈妈一起去超市买东西。\n在超市里，我看到了一个很好玩的玩具，它的名字叫“机器人”。它有一个圆圆的脑袋，两只圆圆的眼睛，还有一个圆圆的''',
					    '''新年快乐，万事如意！在这辞旧迎新的美好时刻，我谨代表《农村新技术》杂志社全体同仁，向一直以来关心、支持《农村新技术》杂志发展的各级领导、各界朋友和广大读者致以最诚挚的''',
					]
					A__	:						Optional[int]								=				tokenizer(UpperCamelCase__					,							return_tensors='''pt'''					,							padding=UpperCamelCase__		)
					A__	:						Any								=				model.generate(**UpperCamelCase__		)
					A__	:						Optional[Any]								=				tokenizer.batch_decode(UpperCamelCase__		)
					self.assertEqual(UpperCamelCase__					,							UpperCamelCase__		)