'''simple docstring'''




import argparse
import json
import os
import re
import shutil

import torch

from transformers import BioGptConfig, BioGptForCausalLM
from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES
from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE
from transformers.utils import WEIGHTS_NAME, logging


logging.set_verbosity_warning()

__UpperCAmelCase     							=2




class     a__      :






     def __init__( self		:		int  ,				*,  # begin keyword-only arguments
         a		:		Dict="<s>"  ,				a		:		Dict="<pad>"  ,				a		:		int="</s>"  ,				a		:		List[Any]="<unk>"  ,				a		:		int=None  ,				):





         """simple docstring"""



         __lowerCamelCase	,  __lowerCamelCase	,  __lowerCamelCase	,  __lowerCamelCase		=  bos, unk, pad, eos
         __lowerCamelCase		=  []
         __lowerCamelCase		=  []
         __lowerCamelCase		=  {}
         __lowerCamelCase		=  self.add_symbol(a    )
         __lowerCamelCase		=  self.add_symbol(a    )
         __lowerCamelCase		=  self.add_symbol(a    )
         __lowerCamelCase		=  self.add_symbol(a    )
         if extra_special_symbols:
             for s in extra_special_symbols:
                 self.add_symbol(a    )
         __lowerCamelCase		=  len(self.symbols    )






     def __eq__( self		:		Dict  ,				a		:		Tuple    ):





         """simple docstring"""



         return self.indices == other.indices






     def __getitem__( self		:		List[Any]  ,				a		:		Tuple    ):





         """simple docstring"""



         if idx < len(self.symbols    ):
             return self.symbols[idx]
         return self.unk_word






     def __len__( self		:		List[str]    ):





         """simple docstring"""



         return len(self.symbols    )






     def __contains__( self		:		Optional[int]  ,				a		:		List[str]    ):





         """simple docstring"""



         return sym in self.indices






     @classmethod
     def    SCREAMING_SNAKE_CASE__   ( cls		:		str  ,				a		:		Dict    ):





         """simple docstring"""



         __lowerCamelCase		=  cls()
         d.add_from_file(a    )
         return d






     def    SCREAMING_SNAKE_CASE__   ( self		:		Any  ,				a		:		Tuple  ,				a		:		Any=1  ,				a		:		List[str]=False    ):





         """simple docstring"""



         if word in self.indices and not overwrite:
             __lowerCamelCase		=  self.indices[word]
             __lowerCamelCase		=  self.count[idx] + n
             return idx
         else:
             __lowerCamelCase		=  len(self.symbols    )
             __lowerCamelCase		=  idx
             self.symbols.append(a    )
             self.count.append(a    )
             return idx






     def    SCREAMING_SNAKE_CASE__   ( self		:		List[str]  ,				a		:		Any    ):





         """simple docstring"""



         return 0






     def    SCREAMING_SNAKE_CASE__   ( self		:		Any  ,				a		:		str    ):





         """simple docstring"""



         if isinstance(a  ,				a    ):
             try:
                 with open(a  ,				'''r'''  ,				encoding='''utf-8'''    ) as fd:
                     self.add_from_file(a    )
             except FileNotFoundError as fnfe:
                 raise fnfe
             except UnicodeError:
                 raise Exception('''Incorrect encoding detected in {}, please rebuild the dataset'''.format(a    )    )
             return

         __lowerCamelCase		=  f.readlines()
         __lowerCamelCase		=  self._load_meta(a    )

         for line in lines[indices_start_line:]:
             try:
                 __lowerCamelCase	,  __lowerCamelCase		=  line.rstrip().rsplit(''' '''  ,				1    )
                 if field == "#fairseq:overwrite":
                     __lowerCamelCase		=  True
                     __lowerCamelCase	,  __lowerCamelCase		=  line.rsplit(''' '''  ,				1    )
                 else:
                     __lowerCamelCase		=  False
                 __lowerCamelCase		=  int(a    )
                 __lowerCamelCase		=  line
                 if word in self and not overwrite:
                     raise RuntimeError(
                         '''Duplicate word found when loading Dictionary: \'{}\'. '''
                         '''Duplicate words can overwrite earlier ones by adding the '''
                         '''#fairseq:overwrite flag at the end of the corresponding row '''
                         '''in the dictionary file. If using the Camembert model, please '''
                         '''download an updated copy of the model file.'''.format(a    )    )
                 self.add_symbol(a  ,				n=a  ,				overwrite=a    )
             except ValueError:
                 raise ValueError('''Incorrect dictionary format, expected \'<token> <cnt> [flags]\''''    )






def __lowerCAmelCase (							UpperCamelCase__				)	->    Tuple:
    # (1) remove word breaking symbol, (2) add word ending symbol where the word is not broken up,
    # e.g.: d = {'le@@': 5, 'tt@@': 6, 'er': 7} => {'le': 5, 'tt': 6, 'er</w>': 7}
    __lowerCamelCase		=  dict((re.sub(r'''@@$'''				,  ''''''				,  UpperCamelCase__				), v) if k.endswith('''@@'''				) else (re.sub(r'''$'''				,  '''</w>'''				,  UpperCamelCase__				), v) for k, v in d.items()				)
    __lowerCamelCase		=  '''<s> <pad> </s> <unk>'''.split()
    # restore the special tokens
    for k in keep_keys:
        del da[f"""{k}</w>"""]
        __lowerCamelCase		=  d[k]  # restore
    return da






def __lowerCAmelCase (							UpperCamelCase__				,  UpperCamelCase__				)	->    Union[str, Any]:
    # prep
    if not os.path.exists(UpperCamelCase__				):
        raise ValueError(f"""path {biogpt_checkpoint_path} does not exist!"""				)
    os.makedirs(UpperCamelCase__				,  exist_ok=UpperCamelCase__				)
    print(f"""Writing results to {pytorch_dump_folder_path}"""				)

    # handle various types of models

    __lowerCamelCase		=  os.path.join(UpperCamelCase__				,  '''checkpoint.pt'''				)
    if not os.path.isfile(UpperCamelCase__				):
        raise ValueError(f"""path to the file {checkpoint_file} does not exist!"""				)
    __lowerCamelCase		=  torch.load(UpperCamelCase__				,  map_location='''cpu'''				)

    __lowerCamelCase		=  chkpt['''cfg''']['''model''']

    # dicts
    __lowerCamelCase		=  os.path.join(UpperCamelCase__				,  '''dict.txt'''				)
    if not os.path.isfile(UpperCamelCase__				):
        raise ValueError(f"""path to the file {dict_file} does not exist!"""				)
    __lowerCamelCase		=  Dictionary.load(UpperCamelCase__				)
    __lowerCamelCase		=  rewrite_dict_keys(src_dict.indices				)
    __lowerCamelCase		=  len(UpperCamelCase__				)
    __lowerCamelCase		=  os.path.join(UpperCamelCase__				,  VOCAB_FILES_NAMES['''vocab_file''']				)
    print(f"""Generating {src_vocab_file} of {src_vocab_size} records"""				)
    with open(UpperCamelCase__				,  '''w'''				,  encoding='''utf-8'''				) as f:
        f.write(json.dumps(UpperCamelCase__				,  ensure_ascii=UpperCamelCase__				,  indent=UpperCamelCase__				)				)

    # merges_file (bpecodes)
    __lowerCamelCase		=  os.path.join(UpperCamelCase__				,  '''bpecodes'''				)
    if not os.path.isfile(UpperCamelCase__				):
        raise ValueError(f"""path to the file {bpecodes_file} does not exist!"""				)

    __lowerCamelCase		=  os.path.join(UpperCamelCase__				,  VOCAB_FILES_NAMES['''merges_file''']				)
    shutil.copyfile(UpperCamelCase__				,  UpperCamelCase__				)

    # model config
    __lowerCamelCase		=  os.path.join(UpperCamelCase__				,  '''config.json'''				)

    __lowerCamelCase		=  {
        '''activation_dropout''': args['''activation_dropout'''],
        '''architectures''': ['''BioGptForCausalLM'''],
        '''attention_probs_dropout_prob''': args['''attention_dropout'''],
        '''bos_token_id''': 0,
        '''eos_token_id''': 2,
        '''hidden_act''': args['''activation_fn'''],
        '''hidden_dropout_prob''': args['''dropout'''],
        '''hidden_size''': args['''decoder_embed_dim'''],
        '''initializer_range''': 0.0_2,
        '''intermediate_size''': args['''decoder_ffn_embed_dim'''],
        '''layer_norm_eps''': 1E-12,
        '''layerdrop''': args['''decoder_layerdrop'''],
        '''max_position_embeddings''': args['''max_target_positions'''],
        '''model_type''': '''biogpt''',
        '''num_attention_heads''': args['''decoder_attention_heads'''],
        '''num_hidden_layers''': args['''decoder_layers'''],
        '''pad_token_id''': 1,
        '''scale_embedding''': not args['''no_scale_embedding'''],
        '''tie_word_embeddings''': args['''share_decoder_input_output_embed'''],
        '''vocab_size''': src_vocab_size,
    }

    # good hparam defaults to start with

    print(f"""Generating {biogpt_model_config_file}"""				)
    with open(UpperCamelCase__				,  '''w'''				,  encoding='''utf-8'''				) as f:
        f.write(json.dumps(UpperCamelCase__				,  ensure_ascii=UpperCamelCase__				,  indent=UpperCamelCase__				)				)

    # tokenizer config
    __lowerCamelCase		=  os.path.join(UpperCamelCase__				,  UpperCamelCase__				)

    __lowerCamelCase		=  {
        '''bos_token''': '''<s>''',
        '''eos_token''': '''</s>''',
        '''model_max_length''': 10_24,
        '''pad_token''': '''<pad>''',
        '''special_tokens_map_file''': None,
        '''tokenizer_class''': '''BioGptTokenizer''',
        '''unk_token''': '''<unk>''',
    }

    print(f"""Generating {biogpt_tokenizer_config_file}"""				)
    with open(UpperCamelCase__				,  '''w'''				,  encoding='''utf-8'''				) as f:
        f.write(json.dumps(UpperCamelCase__				,  ensure_ascii=UpperCamelCase__				,  indent=UpperCamelCase__				)				)

    # model
    __lowerCamelCase		=  chkpt['''model''']

    # remove unneeded keys
    __lowerCamelCase		=  [
        '''decoder.version''',
    ]
    for k in ignore_keys:
        model_state_dict.pop(UpperCamelCase__				,  UpperCamelCase__				)

    __lowerCamelCase		=  list(model_state_dict.keys()				)
    for layer_name in layer_names:
        if layer_name.endswith('''output_projection.weight'''				):
            __lowerCamelCase		=  model_state_dict.pop(UpperCamelCase__				)
        else:
            __lowerCamelCase		=  model_state_dict.pop(UpperCamelCase__				)

    __lowerCamelCase		=  BioGptConfig.from_pretrained(UpperCamelCase__				)
    __lowerCamelCase		=  BioGptForCausalLM(UpperCamelCase__				)

    # check that it loads ok
    model_new.load_state_dict(UpperCamelCase__				)

    # save
    __lowerCamelCase		=  os.path.join(UpperCamelCase__				,  UpperCamelCase__				)
    print(f"""Generating {pytorch_weights_dump_path}"""				)
    torch.save(UpperCamelCase__				,  UpperCamelCase__				)

    print('''Conversion is done!'''				)


if __name__ == "__main__":
  __UpperCAmelCase     							=argparse.ArgumentParser()
  # Required parameters
  parser.add_argument(
      "--biogpt_checkpoint_path",
      default=None,
      type=str,
      required=True,
      help=(
          "Path to the official PyTorch checkpoint file which is expected to reside in the dump dir with dicts,"
          " bpecodes, etc."
      ),
  )
  parser.add_argument(
      "--pytorch_dump_folder_path", default=None, type=str, required=True, help="Path to the output PyTorch model."
  )
  __UpperCAmelCase     							=parser.parse_args()
  convert_biogpt_checkpoint_to_pytorch(args.biogpt_checkpoint_path, args.pytorch_dump_folder_path)





"""simple docstring"""

import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
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 (
         OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST,
         OpenAIGPTConfig,
         OpenAIGPTDoubleHeadsModel,
         OpenAIGPTForSequenceClassification,
         OpenAIGPTLMHeadModel,
         OpenAIGPTModel,
     )




class        _UpperCAmelCase       :

 def __init__(     self		:       Union[str, Any]  ,     lowercase_		:       List[Any]  ,     lowercase_		:       int=13  ,     lowercase_		:       Optional[int]=7  ,     lowercase_		:       Any=True  ,     lowercase_		:       Dict=True  ,     lowercase_		:       Dict=True  ,     lowercase_		:       Optional[Any]=99  ,     lowercase_		:       Union[str, Any]=32  ,     lowercase_		:       str=5  ,     lowercase_		:       Union[str, Any]=4  ,     lowercase_		:       Any=37  ,     lowercase_		:       Tuple="gelu"  ,     lowercase_		:       Dict=0.1  ,     lowercase_		:       Tuple=0.1  ,     lowercase_		:       Optional[int]=512  ,     lowercase_		:       Optional[Any]=16  ,     lowercase_		:       Optional[Any]=2  ,     lowercase_		:       Optional[Any]=0.02  ,     lowercase_		:       List[Any]=3  ,     lowercase_		:       Union[str, Any]=4  ,     lowercase_		:       List[Any]=None  ,     ):
     snake_case_ :     Any				=	parent
     snake_case_ :     List[str]				=	batch_size
     snake_case_ :     List[Any]				=	seq_length
     snake_case_ :     Optional[int]				=	is_training
     snake_case_ :     Union[str, Any]				=	use_token_type_ids
     snake_case_ :     Optional[Any]				=	use_labels
     snake_case_ :     Union[str, Any]				=	vocab_size
     snake_case_ :     Any				=	hidden_size
     snake_case_ :     List[Any]				=	num_hidden_layers
     snake_case_ :     Any				=	num_attention_heads
     snake_case_ :     Dict				=	intermediate_size
     snake_case_ :     Union[str, Any]				=	hidden_act
     snake_case_ :     Optional[int]				=	hidden_dropout_prob
     snake_case_ :     Optional[Any]				=	attention_probs_dropout_prob
     snake_case_ :     Tuple				=	max_position_embeddings
     snake_case_ :     int				=	type_vocab_size
     snake_case_ :     Tuple				=	type_sequence_label_size
     snake_case_ :     str				=	initializer_range
     snake_case_ :     Tuple				=	num_labels
     snake_case_ :     str				=	num_choices
     snake_case_ :     Any				=	scope
     snake_case_ :     Dict				=	self.vocab_size - 1

 def 						_snake_case					(     self		:       int				):
     snake_case_ :     Optional[Any]				=	ids_tensor([self.batch_size, self.seq_length]  ,     self.vocab_size				)

     snake_case_ :     Optional[Any]				=	None
     if self.use_token_type_ids:
         snake_case_ :     Tuple				=	ids_tensor([self.batch_size, self.seq_length]  ,     self.type_vocab_size				)

     snake_case_ :     str				=	None
     snake_case_ :     Dict				=	None
     snake_case_ :     str				=	None
     if self.use_labels:
         snake_case_ :     Optional[int]				=	ids_tensor([self.batch_size]  ,     self.type_sequence_label_size				)
         snake_case_ :     List[Any]				=	ids_tensor([self.batch_size, self.seq_length]  ,     self.num_labels				)
         snake_case_ :     Tuple				=	ids_tensor([self.batch_size]  ,     self.num_choices				)

     snake_case_ :     int				=	OpenAIGPTConfig(
         vocab_size=self.vocab_size  ,     n_embd=self.hidden_size  ,     n_layer=self.num_hidden_layers  ,     n_head=self.num_attention_heads  ,     n_positions=self.max_position_embeddings  ,     pad_token_id=self.pad_token_id  ,     )

     snake_case_ :     Any				=	ids_tensor([self.num_hidden_layers, self.num_attention_heads]  ,     2				)

     return (
         config,
         input_ids,
         head_mask,
         token_type_ids,
         sequence_labels,
         token_labels,
         choice_labels,
     )

 def 						_snake_case					(     self		:       Tuple  ,     lowercase_		:       Any  ,     lowercase_		:       Union[str, Any]  ,     lowercase_		:       str  ,     lowercase_		:       Dict  ,     *lowercase_		:       Dict				):
     snake_case_ :     List[Any]				=	OpenAIGPTModel(config=lowercase_				)
     model.to(lowercase_				)
     model.eval()

     snake_case_ :     Any				=	model(lowercase_  ,     token_type_ids=lowercase_  ,     head_mask=lowercase_				)
     snake_case_ :     Optional[Any]				=	model(lowercase_  ,     token_type_ids=lowercase_				)
     snake_case_ :     Optional[Any]				=	model(lowercase_				)

     self.parent.assertEqual(result.last_hidden_state.shape  ,     (self.batch_size, self.seq_length, self.hidden_size)				)

 def 						_snake_case					(     self		:       Tuple  ,     lowercase_		:       Dict  ,     lowercase_		:       str  ,     lowercase_		:       Optional[Any]  ,     lowercase_		:       List[Any]  ,     *lowercase_		:       Optional[Any]				):
     snake_case_ :     Union[str, Any]				=	OpenAIGPTLMHeadModel(lowercase_				)
     model.to(lowercase_				)
     model.eval()

     snake_case_ :     Union[str, Any]				=	model(lowercase_  ,     token_type_ids=lowercase_  ,     labels=lowercase_				)
     self.parent.assertEqual(result.loss.shape  ,     ()				)
     self.parent.assertEqual(result.logits.shape  ,     (self.batch_size, self.seq_length, self.vocab_size)				)

 def 						_snake_case					(     self		:       List[str]  ,     lowercase_		:       Dict  ,     lowercase_		:       List[str]  ,     lowercase_		:       Any  ,     lowercase_		:       Dict  ,     *lowercase_		:       Union[str, Any]				):
     snake_case_ :     Tuple				=	OpenAIGPTDoubleHeadsModel(lowercase_				)
     model.to(lowercase_				)
     model.eval()

     snake_case_ :     Dict				=	model(lowercase_  ,     token_type_ids=lowercase_  ,     labels=lowercase_				)
     self.parent.assertEqual(result.loss.shape  ,     ()				)
     self.parent.assertEqual(result.logits.shape  ,     (self.batch_size, self.seq_length, self.vocab_size)				)

 def 						_snake_case					(     self		:       Any  ,     lowercase_		:       str  ,     lowercase_		:       List[str]  ,     lowercase_		:       Optional[Any]  ,     lowercase_		:       Optional[Any]  ,     *lowercase_		:       Any				):
     snake_case_ :     int				=	self.num_labels
     snake_case_ :     Any				=	OpenAIGPTForSequenceClassification(lowercase_				)
     model.to(lowercase_				)
     model.eval()

     snake_case_ :     Optional[int]				=	ids_tensor([self.batch_size]  ,     self.type_sequence_label_size				)
     snake_case_ :     Optional[Any]				=	model(lowercase_  ,     token_type_ids=lowercase_  ,     labels=lowercase_				)
     self.parent.assertEqual(result.logits.shape  ,     (self.batch_size, self.num_labels)				)






 def 						_snake_case					(     self		:       int				):
     snake_case_ :     Dict				=	self.prepare_config_and_inputs()
     (
         (
         snake_case_
     ),	(
         snake_case_
     ),	(
         snake_case_
     ),	(
         snake_case_
     ),	(
         snake_case_
     ),	(
         snake_case_
     ),	(
         snake_case_
     ),	
     ) :     str				=	config_and_inputs
     snake_case_ :     str				=	{
         '''input_ids''': input_ids,
         '''token_type_ids''': token_type_ids,
         '''head_mask''': head_mask,
     }

     return config, inputs_dict





@require_torch
class        _UpperCAmelCase       (			lowerCAmelCase__    ,     lowerCAmelCase__    ,     lowerCAmelCase__    ,     unittest.TestCase):
 _lowerCAmelCase   :			Dict							=		(
     (OpenAIGPTModel, OpenAIGPTLMHeadModel, OpenAIGPTDoubleHeadsModel, OpenAIGPTForSequenceClassification)
     if is_torch_available()
     else ()
 )
 _lowerCAmelCase   :			int							=		(
     (OpenAIGPTLMHeadModel,) if is_torch_available() else ()
 )  # TODO (PVP): Add Double HeadsModel when generate() function is changed accordingly
 _lowerCAmelCase   :			Union[str, Any]							=		(
     {
         """feature-extraction""": OpenAIGPTModel,
         """text-classification""": OpenAIGPTForSequenceClassification,
         """text-generation""": OpenAIGPTLMHeadModel,
         """zero-shot""": OpenAIGPTForSequenceClassification,
     }
     if is_torch_available()
     else {}
 )

 def 						_snake_case					(     self		:       Tuple  ,     lowercase_		:       Optional[int]  ,     lowercase_		:       int  ,     lowercase_		:       List[Any]  ,     lowercase_		:       List[Any]  ,     lowercase_		:       Union[str, Any]				):
     if pipeline_test_casse_name == "ZeroShotClassificationPipelineTests":
         # Get `tokenizer does not have a padding token` error for both fast/slow tokenizers.
         # `OpenAIGPTConfig` was never used in pipeline tests, either because of a missing checkpoint or because a
         # tiny config could not be created.
         return True

     return False

 def 						_snake_case					(     self		:       Optional[int]  ,     lowercase_		:       List[Any]  ,     lowercase_		:       Optional[int]  ,     lowercase_		:       List[str]=False				):
     snake_case_ :     Dict				=	super()._prepare_for_class(lowercase_  ,     lowercase_  ,     return_labels=lowercase_				)

     if return_labels:
         if model_class.__name__ == "OpenAIGPTDoubleHeadsModel":
             snake_case_ :     List[str]				=	torch.zeros(
                 (self.model_tester.batch_size, self.model_tester.num_choices, self.model_tester.seq_length)  ,     dtype=torch.long  ,     device=lowercase_  ,     )
             snake_case_ :     int				=	inputs_dict['''labels''']
             snake_case_ :     Optional[Any]				=	inputs_dict['''labels''']
             snake_case_ :     int				=	torch.zeros(
                 (self.model_tester.batch_size, self.model_tester.num_choices)  ,     dtype=torch.long  ,     device=lowercase_  ,     )
             snake_case_ :     Tuple				=	torch.zeros(
                 self.model_tester.batch_size  ,     dtype=torch.long  ,     device=lowercase_				)
     return inputs_dict

 def 						_snake_case					(     self		:       Any				):
     snake_case_ :     List[str]				=	OpenAIGPTModelTester(self				)
     snake_case_ :     Dict				=	ConfigTester(self  ,     config_class=lowercase_  ,     n_embd=37				)

 def 						_snake_case					(     self		:       List[str]				):
     self.config_tester.run_common_tests()

 def 						_snake_case					(     self		:       Optional[Any]				):
     snake_case_ :     Tuple				=	self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_openai_gpt_model(*lowercase_				)

 def 						_snake_case					(     self		:       List[str]				):
     snake_case_ :     List[str]				=	self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_lm_head_model(*lowercase_				)

 def 						_snake_case					(     self		:       int				):
     snake_case_ :     Any				=	self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_double_lm_head_model(*lowercase_				)

 def 						_snake_case					(     self		:       List[str]				):
     snake_case_ :     Optional[int]				=	self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_openai_gpt_for_sequence_classification(*lowercase_				)






 @slow
 def 						_snake_case					(     self		:       Dict				):
     for model_name in OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         snake_case_ :     Optional[Any]				=	OpenAIGPTModel.from_pretrained(lowercase_				)
         self.assertIsNotNone(lowercase_				)





@require_torch
class        _UpperCAmelCase       (			unittest.TestCase):

 @slow
 def 						_snake_case					(     self		:       Optional[int]				):
     snake_case_ :     Optional[Any]				=	OpenAIGPTLMHeadModel.from_pretrained('''openai-gpt'''				)
     model.to(lowercase_				)
     snake_case_ :     List[str]				=	torch.tensor([[481, 4735, 544]]  ,     dtype=torch.long  ,     device=lowercase_				)  # the president is
     snake_case_ :     List[Any]				=	[
         481,
         4735,
         544,
         246,
         963,
         870,
         762,
         239,
         244,
         40477,
         244,
         249,
         719,
         881,
         487,
         544,
         240,
         244,
         603,
         481,
     ]  # the president is a very good man. " \n " i\'m sure he is, " said the

     snake_case_ :     Optional[Any]				=	model.generate(lowercase_  ,     do_sample=lowercase_				)
     self.assertListEqual(output_ids[0].tolist()  ,     lowercase_				)





