



'''simple docstring'''
import unittest

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

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
					import torch

					from transformers import (
					    ErnieMForInformationExtraction,
					    ErnieMForMultipleChoice,
					    ErnieMForQuestionAnswering,
					    ErnieMForSequenceClassification,
					    ErnieMForTokenClassification,
					    ErnieMModel,
					)
					from transformers.models.ernie_m.modeling_ernie_m import ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST






class 							lowercase__			:





	def __init__(				self      :       Dict				,lowerCamelCase__      :       List[str]				,lowerCamelCase__      :       Optional[int]=13				,lowerCamelCase__      :       Tuple=7				,lowerCamelCase__      :       str=True				,lowerCamelCase__      :       List[Any]=True				,lowerCamelCase__      :       Tuple=True				,lowerCamelCase__      :       Tuple=99				,lowerCamelCase__      :       int=32				,lowerCamelCase__      :       Tuple=5				,lowerCamelCase__      :       Union[str, Any]=4				,lowerCamelCase__      :       List[Any]=37				,lowerCamelCase__      :       Optional[int]="gelu"				,lowerCamelCase__      :       List[Any]=0.1				,lowerCamelCase__      :       str=0.1				,lowerCamelCase__      :       Union[str, Any]=512				,lowerCamelCase__      :       Optional[Any]=16				,lowerCamelCase__      :       Union[str, Any]=2				,lowerCamelCase__      :       Optional[int]=0.0_2				,lowerCamelCase__      :       List[Any]=3				,lowerCamelCase__      :       Tuple=4				,lowerCamelCase__      :       Tuple=None				,):







							'''simple docstring'''
							_UpperCamelCase      :	Optional[int]				       =     parent
							_UpperCamelCase      :	Dict				       =     batch_size
							_UpperCamelCase      :	Optional[int]				       =     seq_length
							_UpperCamelCase      :	Optional[Any]				       =     is_training
							_UpperCamelCase      :	Dict				       =     use_input_mask
							_UpperCamelCase      :	str				       =     use_labels
							_UpperCamelCase      :	Optional[Any]				       =     vocab_size
							_UpperCamelCase      :	Any				       =     hidden_size
							_UpperCamelCase      :	Optional[Any]				       =     num_hidden_layers
							_UpperCamelCase      :	Tuple				       =     num_attention_heads
							_UpperCamelCase      :	str				       =     intermediate_size
							_UpperCamelCase      :	Union[str, Any]				       =     hidden_act
							_UpperCamelCase      :	Any				       =     hidden_dropout_prob
							_UpperCamelCase      :	Optional[Any]				       =     attention_probs_dropout_prob
							_UpperCamelCase      :	Union[str, Any]				       =     max_position_embeddings
							_UpperCamelCase      :	Optional[int]				       =     type_vocab_size
							_UpperCamelCase      :	Optional[int]				       =     type_sequence_label_size
							_UpperCamelCase      :	int				       =     initializer_range
							_UpperCamelCase      :	str				       =     num_labels
							_UpperCamelCase      :	Union[str, Any]				       =     num_choices
							_UpperCamelCase      :	Any				       =     scope





	def 			UpperCamelCase_						(				self      :       List[str]				):







							'''simple docstring'''
							_UpperCamelCase      :	List[Any]				       =     ids_tensor([self.batch_size, self.seq_length]				,self.vocab_size				)

							_UpperCamelCase      :	Optional[Any]				       =     None
							if self.use_input_mask:
													_UpperCamelCase      :	Dict				       =     random_attention_mask([self.batch_size, self.seq_length]				)

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

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

							return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels





	def 			UpperCamelCase_						(				self      :       Union[str, Any]				):







							'''simple docstring'''
							_UpperCamelCase      :	Tuple				       =     ids_tensor([self.batch_size, self.seq_length]				,self.vocab_size				)

							_UpperCamelCase      :	Any				       =     None
							if self.use_input_mask:
													_UpperCamelCase      :	List[str]				       =     random_attention_mask([self.batch_size, self.seq_length]				)
							_UpperCamelCase      :	Union[str, Any]				       =     self.get_config()

							return config, input_ids, input_mask





	def 			UpperCamelCase_						(				self      :       Dict				):







							'''simple docstring'''
							return ErnieMConfig(
							    vocab_size=self.vocab_size				,hidden_size=self.hidden_size				,num_hidden_layers=self.num_hidden_layers				,num_attention_heads=self.num_attention_heads				,intermediate_size=self.intermediate_size				,hidden_act=self.hidden_act				,hidden_dropout_prob=self.hidden_dropout_prob				,attention_probs_dropout_prob=self.attention_probs_dropout_prob				,max_position_embeddings=self.max_position_embeddings				,type_vocab_size=self.type_vocab_size				,initializer_range=self.initializer_range				,)





	def 			UpperCamelCase_						(				self      :       Optional[int]				,lowerCamelCase__      :       str				,lowerCamelCase__      :       Any				,lowerCamelCase__      :       List[str]				,lowerCamelCase__      :       List[str]				,lowerCamelCase__      :       str				,lowerCamelCase__      :       str				):







							'''simple docstring'''
							_UpperCamelCase      :	List[str]				       =     ErnieMModel(config=SCREAMING_SNAKE_CASE_				)
							model.to(SCREAMING_SNAKE_CASE_				)
							model.eval()
							_UpperCamelCase      :	Union[str, Any]				       =     model(SCREAMING_SNAKE_CASE_				,return_dict=SCREAMING_SNAKE_CASE_				)
							self.parent.assertEqual(result.last_hidden_state.shape				,(self.batch_size, self.seq_length, self.hidden_size)				)





	def 			UpperCamelCase_						(				self      :       Optional[Any]				,lowerCamelCase__      :       str				,lowerCamelCase__      :       Tuple				,lowerCamelCase__      :       Optional[int]				,lowerCamelCase__      :       Tuple				,lowerCamelCase__      :       Union[str, Any]				,lowerCamelCase__      :       Dict				):







							'''simple docstring'''
							_UpperCamelCase      :	Union[str, Any]				       =     ErnieMForQuestionAnswering(config=SCREAMING_SNAKE_CASE_				)
							model.to(SCREAMING_SNAKE_CASE_				)
							model.eval()
							_UpperCamelCase      :	Optional[int]				       =     model(
							    SCREAMING_SNAKE_CASE_				,attention_mask=SCREAMING_SNAKE_CASE_				,start_positions=SCREAMING_SNAKE_CASE_				,end_positions=SCREAMING_SNAKE_CASE_				,)
							self.parent.assertEqual(result.start_logits.shape				,(self.batch_size, self.seq_length)				)
							self.parent.assertEqual(result.end_logits.shape				,(self.batch_size, self.seq_length)				)





	def 			UpperCamelCase_						(				self      :       Optional[Any]				,lowerCamelCase__      :       Any				,lowerCamelCase__      :       Optional[int]				,lowerCamelCase__      :       str				,lowerCamelCase__      :       Optional[int]				,lowerCamelCase__      :       Tuple				,lowerCamelCase__      :       List[Any]				):







							'''simple docstring'''
							_UpperCamelCase      :	Any				       =     ErnieMForInformationExtraction(config=SCREAMING_SNAKE_CASE_				)
							model.to(SCREAMING_SNAKE_CASE_				)
							model.eval()
							_UpperCamelCase      :	str				       =     torch.ones_like(SCREAMING_SNAKE_CASE_				,dtype=torch.floataa				)
							_UpperCamelCase      :	Optional[int]				       =     model(
							    SCREAMING_SNAKE_CASE_				,attention_mask=SCREAMING_SNAKE_CASE_				,start_positions=SCREAMING_SNAKE_CASE_				,end_positions=SCREAMING_SNAKE_CASE_				,)
							self.parent.assertEqual(result.start_logits.shape				,(self.batch_size, self.seq_length)				)
							self.parent.assertEqual(result.end_logits.shape				,(self.batch_size, self.seq_length)				)





	def 			UpperCamelCase_						(				self      :       Optional[Any]				,lowerCamelCase__      :       Any				,lowerCamelCase__      :       Union[str, Any]				,lowerCamelCase__      :       Dict				,lowerCamelCase__      :       Optional[Any]				,lowerCamelCase__      :       Union[str, Any]				,lowerCamelCase__      :       Optional[Any]				):







							'''simple docstring'''
							_UpperCamelCase      :	Optional[int]				       =     self.num_labels
							_UpperCamelCase      :	Optional[int]				       =     ErnieMForSequenceClassification(SCREAMING_SNAKE_CASE_				)
							model.to(SCREAMING_SNAKE_CASE_				)
							model.eval()
							_UpperCamelCase      :	List[Any]				       =     model(SCREAMING_SNAKE_CASE_				,attention_mask=SCREAMING_SNAKE_CASE_				,labels=SCREAMING_SNAKE_CASE_				)
							self.parent.assertEqual(result.logits.shape				,(self.batch_size, self.num_labels)				)





	def 			UpperCamelCase_						(				self      :       Dict				,lowerCamelCase__      :       str				,lowerCamelCase__      :       str				,lowerCamelCase__      :       Optional[Any]				,lowerCamelCase__      :       Dict				,lowerCamelCase__      :       List[Any]				,lowerCamelCase__      :       List[str]				):







							'''simple docstring'''
							_UpperCamelCase      :	int				       =     self.num_labels
							_UpperCamelCase      :	Union[str, Any]				       =     ErnieMForTokenClassification(config=SCREAMING_SNAKE_CASE_				)
							model.to(SCREAMING_SNAKE_CASE_				)
							model.eval()
							input_ids.to(SCREAMING_SNAKE_CASE_				)
							input_mask.to(SCREAMING_SNAKE_CASE_				)
							token_labels.to(SCREAMING_SNAKE_CASE_				)

							_UpperCamelCase      :	List[str]				       =     model(SCREAMING_SNAKE_CASE_				,attention_mask=SCREAMING_SNAKE_CASE_				,labels=SCREAMING_SNAKE_CASE_				)

							self.parent.assertEqual(result.logits.shape				,(self.batch_size, self.seq_length, self.num_labels)				)





	def 			UpperCamelCase_						(				self      :       List[Any]				,lowerCamelCase__      :       Any				,lowerCamelCase__      :       Union[str, Any]				,lowerCamelCase__      :       Tuple				,lowerCamelCase__      :       str				,lowerCamelCase__      :       int				,lowerCamelCase__      :       Union[str, Any]				):







							'''simple docstring'''
							_UpperCamelCase      :	int				       =     self.num_choices
							_UpperCamelCase      :	Any				       =     ErnieMForMultipleChoice(config=SCREAMING_SNAKE_CASE_				)
							model.to(SCREAMING_SNAKE_CASE_				)
							model.eval()
							_UpperCamelCase      :	List[Any]				       =     input_ids.unsqueeze(1				).expand(-1				,self.num_choices				,-1				).contiguous()
							_UpperCamelCase      :	Any				       =     input_mask.unsqueeze(1				).expand(-1				,self.num_choices				,-1				).contiguous()
							_UpperCamelCase      :	str				       =     model(
							    SCREAMING_SNAKE_CASE_				,attention_mask=SCREAMING_SNAKE_CASE_				,labels=SCREAMING_SNAKE_CASE_				,)
							self.parent.assertEqual(result.logits.shape				,(self.batch_size, self.num_choices)				)





	def 			UpperCamelCase_						(				self      :       int				):







							'''simple docstring'''
							_UpperCamelCase      :	Optional[int]				       =     self.prepare_config_and_inputs()
							(
							    _UpperCamelCase  
							)      :	Union[str, Any]				       =     config_and_inputs
							_UpperCamelCase      :	Tuple				       =     {'input_ids': input_ids, 'attention_mask': input_mask}
							return config, inputs_dict






@require_torch
class 							lowercase__			(							a__		,      a__		,      unittest.TestCase     ):
	lowercase__						       =    (
	    (
	        ErnieMModel,
	        ErnieMForMultipleChoice,
	        ErnieMForQuestionAnswering,
	        ErnieMForSequenceClassification,
	        ErnieMForTokenClassification,
	    )
	    if is_torch_available()
	    else ()
	)
	lowercase__						       =    ()
	lowercase__						       =    (
	    {
	        "feature-extraction": ErnieMModel,
	        "question-answering": ErnieMForQuestionAnswering,
	        "text-classification": ErnieMForSequenceClassification,
	        "token-classification": ErnieMForTokenClassification,
	        "zero-shot": ErnieMForSequenceClassification,
	    }
	    if is_torch_available()
	    else {}
	)
	lowercase__						       =    False





	def 			UpperCamelCase_						(				self      :       int				,lowerCamelCase__      :       str				,lowerCamelCase__      :       Any				,lowerCamelCase__      :       Optional[Any]				,lowerCamelCase__      :       Tuple				,lowerCamelCase__      :       Tuple				):







							'''simple docstring'''
							if pipeline_test_casse_name == "QAPipelineTests":
													return True

							return False





	def 			UpperCamelCase_						(				self      :       Dict				):







							'''simple docstring'''
							_UpperCamelCase      :	List[str]				       =     ErnieMModelTester(self				)
							_UpperCamelCase      :	int				       =     ConfigTester(self				,config_class=SCREAMING_SNAKE_CASE_				,hidden_size=37				)





	def 			UpperCamelCase_						(				self      :       Tuple				):







							'''simple docstring'''
							self.config_tester.run_common_tests()





	def 			UpperCamelCase_						(				self      :       Dict				):







							'''simple docstring'''
							_UpperCamelCase      :	List[Any]				       =     self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_				)





	def 			UpperCamelCase_						(				self      :       Tuple				):







							'''simple docstring'''
							_UpperCamelCase      :	Optional[Any]				       =     self.model_tester.prepare_config_and_inputs()
							for type in ["absolute", "relative_key", "relative_key_query"]:
													_UpperCamelCase      :	int				       =     type
													self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_				)





	def 			UpperCamelCase_						(				self      :       str				):







							'''simple docstring'''
							_UpperCamelCase      :	Tuple				       =     self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE_				)





	def 			UpperCamelCase_						(				self      :       Tuple				):







							'''simple docstring'''
							_UpperCamelCase      :	Dict				       =     self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE_				)





	def 			UpperCamelCase_						(				self      :       Any				):







							'''simple docstring'''
							_UpperCamelCase      :	Dict				       =     self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE_				)





	def 			UpperCamelCase_						(				self      :       List[Any]				):







							'''simple docstring'''
							_UpperCamelCase      :	Optional[Any]				       =     self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_information_extraction(*SCREAMING_SNAKE_CASE_				)





	def 			UpperCamelCase_						(				self      :       List[Any]				):







							'''simple docstring'''
							_UpperCamelCase      :	List[Any]				       =     self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_token_classification(*SCREAMING_SNAKE_CASE_				)





	@slow
	def 			UpperCamelCase_						(				self      :       Any				):







							'''simple docstring'''
							for model_name in ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
													_UpperCamelCase      :	List[Any]				       =     ErnieMModel.from_pretrained(SCREAMING_SNAKE_CASE_				)
													self.assertIsNotNone(SCREAMING_SNAKE_CASE_				)






@require_torch
class 							lowercase__			(							unittest.TestCase     ):





	@slow
	def 			UpperCamelCase_						(				self      :       Optional[Any]				):







							'''simple docstring'''
							_UpperCamelCase      :	Optional[Any]				       =     ErnieMModel.from_pretrained('susnato/ernie-m-base_pytorch'				)
							model.eval()
							_UpperCamelCase      :	Optional[Any]				       =     torch.tensor([[0, 1, 2, 3, 4, 5]]				)
							_UpperCamelCase      :	Optional[Any]				       =     model(SCREAMING_SNAKE_CASE_				)[0]

							# TODO Replace vocab size
							_UpperCamelCase      :	Dict				       =     768

							_UpperCamelCase      :	int				       =     torch.Size((1, 6, hidden_size)				)
							self.assertEqual(output.shape				,SCREAMING_SNAKE_CASE_				)

							_UpperCamelCase      :	Optional[Any]				       =     torch.tensor(
							    [[[-0.0_0_1_2, 0.1_2_4_5, -0.0_2_1_4], [-0.0_7_4_2, 0.0_2_4_4, -0.0_7_7_1], [-0.0_3_3_3, 0.1_1_6_4, -0.1_5_5_4]]]				)

							self.assertTrue(torch.allclose(output[:, :3, :3]				,SCREAMING_SNAKE_CASE_				,atol=1E-3				)				)







'''simple docstring'''
import argparse
import time

import torch
import transformers
from measures_util import end_measure, log_measures, start_measure
from transformers import AutoConfig, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoTokenizer

from accelerate.utils import compute_module_sizes


snake_case_				:			str						 =						{
    'gpt-j-6b': {'is_causal': True, 'model': 'sgugger/sharded-gpt-j-6B', 'tokenizer': 'EleutherAI/gpt-j-6B'},
    'gpt-neox': {'is_causal': True, 'model': 'EleutherAI/gpt-neox-20b'},
    'opt': {'is_causal': True, 'model': 'facebook/opt-30b'},
    'T0pp': {'is_causal': False, 'model': 'bigscience/T0pp', 'model_revision': 'sharded'},
}

snake_case_				:			int						 =						[
    'Hello, my name is',
    'Are unicorns real? Unicorns are',
    'For the first time in several years,',
    'My name is Julien and I am',
    'The goal of life is',
    'Whenever I\'m sad, I like to',
]






def A__					(  ):
						_UpperCamelCase      :	Tuple				       =     argparse.ArgumentParser(description='Run and time generations on a big model using Accelerate.'							)
						parser.add_argument('model_name'						,						type=UpperCAmelCase_						,						default=UpperCAmelCase_						,						help='The name of the model to try.'							)
						parser.add_argument(
						    '--tokenizer_name'						,						type=UpperCAmelCase_						,						default=UpperCAmelCase_						,						help='The name of the tokenizer (if different from the model.'							)
						parser.add_argument('--is_causal'						,						type=UpperCAmelCase_						,						default=UpperCAmelCase_						,						help='Whether or not the model is causal.'							)
						parser.add_argument(
						    '--model_revision'						,						type=UpperCAmelCase_						,						default=UpperCAmelCase_						,						help='The revision to use for the model checkpoint.'							)
						parser.add_argument('--torch_dtype'						,						type=UpperCAmelCase_						,						default=UpperCAmelCase_						,						help='The dtype for the model.'							)
						parser.add_argument('--disk_offload'						,						action='store_true'							)

						_UpperCamelCase      :	Dict				       =     parser.parse_args()

						# Sanitize args
						if args.model_name in DEFAULT_MODELS:
												_UpperCamelCase      :	Optional[Any]				       =     DEFAULT_MODELS[args.model_name]
												_UpperCamelCase      :	int				       =     defaults['model']
												if args.tokenizer_name is None:
																		_UpperCamelCase      :	List[str]				       =     defaults.get('tokenizer'						,						args.model_name							)
												if args.is_causal is None:
																		_UpperCamelCase      :	List[Any]				       =     defaults['is_causal']
												if args.model_revision is None:
																		_UpperCamelCase      :	Optional[int]				       =     defaults.get('model_revision'						,						'main'							)

						if args.is_causal is None:
												raise ValueError('Could not infer the default for `--is_causal`, pass either True or False for it.'							)
						if args.tokenizer_name is None:
												_UpperCamelCase      :	List[str]				       =     args.model_name
						if args.model_revision is None:
												_UpperCamelCase      :	List[str]				       =     'main'

						return args






def A__					(  ):
						transformers.utils.logging.set_verbosity_error()
						_UpperCamelCase      :	Optional[Any]				       =     parse_args()

						if args.torch_dtype is None:
												_UpperCamelCase      :	Tuple				       =     AutoConfig.from_pretrained(args.model_name							)
												_UpperCamelCase      :	str				       =     getattr(UpperCAmelCase_						,						'torch_dtype'						,						torch.floataa							)
						else:
												_UpperCamelCase      :	Union[str, Any]				       =     getattr(UpperCAmelCase_						,						args.torch_dtype							)
						_UpperCamelCase      :	int				       =     AutoModelForCausalLM if args.is_causal else AutoModelForSeqaSeqLM
						_UpperCamelCase      :	int				       =     {
						    'torch_dtype': torch_dtype,
						    'revision': args.model_revision,
						}
						if args.disk_offload:
												_UpperCamelCase      :	List[str]				       =     'tmp_offload'
												_UpperCamelCase      :	Union[str, Any]				       =     True

						_UpperCamelCase      :	Dict				       =     start_measure()
						_UpperCamelCase      :	Optional[int]				       =     model_cls.from_pretrained(args.model_name						,						device_map='auto'						,						**UpperCAmelCase_							)
						_UpperCamelCase      :	List[str]				       =     end_measure(UpperCAmelCase_							)
						log_measures(UpperCAmelCase_						,						'Model loading'							)

						_UpperCamelCase      :	Optional[int]				       =     compute_module_sizes(UpperCAmelCase_							)
						_UpperCamelCase      :	str				       =     {v: 0 for v in model.hf_device_map.values()}
						for module, device in model.hf_device_map.items():
												device_size[device] += module_sizes[module]
						_UpperCamelCase      :	Tuple				       =     '\n'.join([f'- {device}: {size // 2**2_0}MiB' for device, size in device_size.items()]							)
						print(f'\nTheoretical use:\n{message}'							)

						_UpperCamelCase      :	List[str]				       =     AutoTokenizer.from_pretrained(args.tokenizer_name							)

						_UpperCamelCase      :	List[str]				       =     start_measure()
						_UpperCamelCase      :	Optional[Any]				       =     []
						_UpperCamelCase      :	Dict				       =     []
						_UpperCamelCase      :	List[str]				       =     []
						for prompt in PROMPTS:
												_UpperCamelCase      :	List[Any]				       =     tokenizer(UpperCAmelCase_						,						return_tensors='pt'							).to(0							)
												_UpperCamelCase      :	List[str]				       =     inputs['input_ids'][0].tolist()
												_UpperCamelCase      :	int				       =     time.time()
												_UpperCamelCase      :	int				       =     model.generate(inputs['input_ids']							)
												_UpperCamelCase      :	int				       =     time.time()
												_UpperCamelCase      :	Optional[Any]				       =     outputs[0].tolist()
												_UpperCamelCase      :	List[Any]				       =     len(UpperCAmelCase_							) if outputs[: len(UpperCAmelCase_							)] != tokens else len(UpperCAmelCase_							) - len(UpperCAmelCase_							)
												_UpperCamelCase      :	Any				       =     after_generate - before_generate

												_UpperCamelCase      :	Optional[int]				       =     tokenizer.decode(UpperCAmelCase_						,						skip_special_tokens=UpperCAmelCase_							)
												texts_outs.append(UpperCAmelCase_							)
												generation_times.append(UpperCAmelCase_							)
												gen_tokens.append(UpperCAmelCase_							)
												print(f'Prompt: {prompt}\nGeneration {text_out}\nIn {generation_time:.2f}s for {num_gen_tokens} tokens\n'							)

						_UpperCamelCase      :	Union[str, Any]				       =     end_measure(UpperCAmelCase_							)
						log_measures(UpperCAmelCase_						,						'Model generation'							)

						_UpperCamelCase      :	str				       =     [gen / tok for gen, tok in zip(UpperCAmelCase_						,						UpperCAmelCase_							)]
						_UpperCamelCase      :	List[Any]				       =     sum(UpperCAmelCase_							) / len(UpperCAmelCase_							)
						print(f'Average time of generation per token: {avg_gen:.2f}s'							)
						print(f'First generation (avg time per token): {generation_times_per_token[0]:.2f}s'							)
						_UpperCamelCase      :	List[Any]				       =     sum(generation_times_per_token[1:]							) / (len(UpperCAmelCase_							) - 1)
						print(f'Average time of generation per token (excluding the first): {avg_gen:.2f}s'							)


if __name__ == "__main__":
					main()


