from dataclasses import dataclass
from typing import List, Optional, Tuple, Union

import numpy as np
import torch

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput, logging, randn_tensor
from .scheduling_utils import SchedulerMixin


lowerCAmelCase__					:       str		=       logging.get_logger(__name__)  # pylint: disable=invalid-name





@dataclass
class 			__snake_case  (      _lowerCamelCase     ):
					__lowerCamelCase	 =       42





class 			__snake_case  (      _lowerCamelCase   ,_lowerCamelCase     ):
					__lowerCamelCase	 =       1




					@register_to_config
					def __init__(       self   ,	__UpperCamelCase = 40   ,	__UpperCamelCase = 0.0_0_2   ,	__UpperCamelCase = 8_0.0   ,	__UpperCamelCase = 0.5   ,	__UpperCamelCase = 1.0   ,	__UpperCamelCase = 7.0   ,	__UpperCamelCase = True   ,	)					->  Tuple:



									'''simple docstring'''







									snake_case__ :     Dict 							=				sigma_max

									snake_case__ :     Optional[Any] 							=				np.linspace(0   ,	1   ,	__UpperCamelCase		)
									snake_case__ :     Tuple 							=				self._convert_to_karras(__UpperCamelCase		)
									snake_case__ :     Dict 							=				self.sigma_to_t(__UpperCamelCase		)

									# setable values
									snake_case__ :     List[str] 							=				None
									snake_case__ :     Tuple 							=				torch.from_numpy(__UpperCamelCase		)
									snake_case__ :     Tuple 							=				torch.from_numpy(__UpperCamelCase		)
									snake_case__ :     Dict 							=				False
									snake_case__ :     List[str] 							=				False




					def       __a      (       self   ,	__UpperCamelCase   ,	__UpperCamelCase=None		)					->  Union[str, Any]:



									'''simple docstring'''







									if schedule_timesteps is None:
													snake_case__ :     Union[str, Any] 							=				self.timesteps

									snake_case__ :     Dict 							=				(schedule_timesteps == timestep).nonzero()
									return indices.item()




					def       __a      (       self   ,	__UpperCamelCase   ,	__UpperCamelCase		)					->  torch.FloatTensor:



									'''simple docstring'''







									if isinstance(__UpperCamelCase   ,	torch.Tensor		):
													snake_case__ :     Optional[Any] 							=				timestep.to(self.timesteps.device		)
									snake_case__ :     Union[str, Any] 							=				self.index_for_timestep(__UpperCamelCase		)
									snake_case__ :     Optional[int] 							=				self.sigmas[step_idx]

									snake_case__ :     int 							=				sample / ((sigma**2 + self.config.sigma_data**2) ** 0.5)

									snake_case__ :     List[str] 							=				True
									return sample




					def       __a      (       self   ,	__UpperCamelCase		)					->  Any:



									'''simple docstring'''







									if not isinstance(__UpperCamelCase   ,	np.ndarray		):
													snake_case__ :     List[str] 							=				np.array(__UpperCamelCase   ,	dtype=np.floataa		)

									snake_case__ :     int 							=				1000 * 0.2_5 * np.log(sigmas + 1E-44		)

									return timesteps




					def       __a      (       self   ,	__UpperCamelCase = None   ,	__UpperCamelCase = None   ,	__UpperCamelCase = None   ,	)					->  Union[str, Any]:



									'''simple docstring'''







									if num_inference_steps is None and timesteps is None:
													raise ValueError('Exactly one of `num_inference_steps` or `timesteps` must be supplied.'		)

									if num_inference_steps is not None and timesteps is not None:
													raise ValueError('Can only pass one of `num_inference_steps` or `timesteps`.'		)

									# Follow DDPMScheduler custom timesteps logic
									if timesteps is not None:
													for i in range(1   ,	len(__UpperCamelCase		)		):
																	if timesteps[i] >= timesteps[i - 1]:
																					raise ValueError('`timesteps` must be in descending order.'		)

													if timesteps[0] >= self.config.num_train_timesteps:
																	raise ValueError(
																	    F"""`timesteps` must start before `self.config.train_timesteps`:"""
																	    F""" {self.config.num_train_timesteps}."""		)

													snake_case__ :     int 							=				np.array(__UpperCamelCase   ,	dtype=np.intaa		)
													snake_case__ :     Dict 							=				True
									else:
													if num_inference_steps > self.config.num_train_timesteps:
																	raise ValueError(
																	    F"""`num_inference_steps`: {num_inference_steps} cannot be larger than `self.config.train_timesteps`:"""
																	    F""" {self.config.num_train_timesteps} as the unet model trained with this scheduler can only handle"""
																	    F""" maximal {self.config.num_train_timesteps} timesteps."""		)

													snake_case__ :     int 							=				num_inference_steps

													snake_case__ :     Any 							=				self.config.num_train_timesteps // self.num_inference_steps
													snake_case__ :     Optional[Any] 							=				(np.arange(0   ,	__UpperCamelCase		) * step_ratio).round()[::-1].copy().astype(np.intaa		)
													snake_case__ :     Any 							=				False

									# Map timesteps to Karras sigmas directly for multistep sampling
									# See https://github.com/openai/consistency_models/blob/main/cm/karras_diffusion.py#L675
									snake_case__ :     Optional[int] 							=				self.config.num_train_timesteps
									snake_case__ :     int 							=				timesteps[::-1].copy()
									snake_case__ :     Union[str, Any] 							=				ramp / (num_train_timesteps - 1)
									snake_case__ :     Dict 							=				self._convert_to_karras(__UpperCamelCase		)
									snake_case__ :     Union[str, Any] 							=				self.sigma_to_t(__UpperCamelCase		)

									snake_case__ :     Any 							=				np.concatenate([sigmas, [self.sigma_min]]		).astype(np.floataa		)
									snake_case__ :     Tuple 							=				torch.from_numpy(__UpperCamelCase		).to(device=__UpperCamelCase		)

									if str(__UpperCamelCase		).startswith('mps'		):
													# mps does not support float64
													snake_case__ :     Dict 							=				torch.from_numpy(__UpperCamelCase		).to(__UpperCamelCase   ,	dtype=torch.floataa		)
									else:
													snake_case__ :     Optional[Any] 							=				torch.from_numpy(__UpperCamelCase		).to(device=__UpperCamelCase		)




					def       __a      (       self   ,	__UpperCamelCase		)					->  List[Any]:



									'''simple docstring'''







									snake_case__ :     float 							=				self.config.sigma_min
									snake_case__ :     float 							=				self.config.sigma_max

									snake_case__ :     int 							=				self.config.rho
									snake_case__ :     List[Any] 							=				sigma_min ** (1 / rho)
									snake_case__ :     Union[str, Any] 							=				sigma_max ** (1 / rho)
									snake_case__ :     Optional[Any] 							=				(max_inv_rho + ramp * (min_inv_rho - max_inv_rho)) ** rho
									return sigmas




					def       __a      (       self   ,	__UpperCamelCase		)					->  Optional[int]:



									'''simple docstring'''







									snake_case__ :     str 							=				self.config.sigma_data

									snake_case__ :     int 							=				sigma_data**2 / (sigma**2 + sigma_data**2)
									snake_case__ :     Any 							=				sigma * sigma_data / (sigma**2 + sigma_data**2) ** 0.5
									return c_skip, c_out




					def       __a      (       self   ,	__UpperCamelCase		)					->  Any:



									'''simple docstring'''







									snake_case__ :     List[str] 							=				self.config.sigma_min
									snake_case__ :     Optional[Any] 							=				self.config.sigma_data

									snake_case__ :     List[Any] 							=				sigma_data**2 / ((sigma - sigma_min) ** 2 + sigma_data**2)
									snake_case__ :     List[Any] 							=				(sigma - sigma_min) * sigma_data / (sigma**2 + sigma_data**2) ** 0.5
									return c_skip, c_out




					def       __a      (       self   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase = None   ,	__UpperCamelCase = True   ,	)					->  Union[CMStochasticIterativeSchedulerOutput, Tuple]:



									'''simple docstring'''







									if (
									    isinstance(__UpperCamelCase   ,	__UpperCamelCase		)
									    or isinstance(__UpperCamelCase   ,	torch.IntTensor		)
									    or isinstance(__UpperCamelCase   ,	torch.LongTensor		)
									):
													raise ValueError(
													    (
													        'Passing integer indices (e.g. from `enumerate(timesteps)`) as timesteps to'
													        F""" `{self.__class__}.step()` is not supported. Make sure to pass"""
													        ' one of the `scheduler.timesteps` as a timestep.'
													    )   ,	)

									if not self.is_scale_input_called:
													logger.warning(
													    'The `scale_model_input` function should be called before `step` to ensure correct denoising. '
													    'See `StableDiffusionPipeline` for a usage example.'		)

									if isinstance(__UpperCamelCase   ,	torch.Tensor		):
													snake_case__ :     Tuple 							=				timestep.to(self.timesteps.device		)

									snake_case__ :     Optional[int] 							=				self.config.sigma_min
									snake_case__ :     int 							=				self.config.sigma_max

									snake_case__ :     List[Any] 							=				self.index_for_timestep(__UpperCamelCase		)

									# sigma_next corresponds to next_t in original implementation
									snake_case__ :     int 							=				self.sigmas[step_index]
									if step_index + 1 < self.config.num_train_timesteps:
													snake_case__ :     Optional[int] 							=				self.sigmas[step_index + 1]
									else:
													# Set sigma_next to sigma_min
													snake_case__ :     str 							=				self.sigmas[-1]

									# Get scalings for boundary conditions
									snake_case__							,  snake_case__ :     List[str] 							=				self.get_scalings_for_boundary_condition(__UpperCamelCase		)

									# 1. Denoise model output using boundary conditions
									snake_case__ :     Dict 							=				c_out * model_output + c_skip * sample
									if self.config.clip_denoised:
													snake_case__ :     Optional[Any] 							=				denoised.clamp(-1   ,	1		)

									# 2. Sample z ~ N(0, s_noise^2 * I)
									# Noise is not used for onestep sampling.
									if len(self.timesteps		) > 1:
													snake_case__ :     List[Any] 							=				randn_tensor(
													    model_output.shape   ,	dtype=model_output.dtype   ,	device=model_output.device   ,	generator=__UpperCamelCase		)
									else:
													snake_case__ :     Union[str, Any] 							=				torch.zeros_like(__UpperCamelCase		)
									snake_case__ :     int 							=				noise * self.config.s_noise

									snake_case__ :     Dict 							=				sigma_next.clamp(min=__UpperCamelCase   ,	max=__UpperCamelCase		)

									# 3. Return noisy sample
									# tau = sigma_hat, eps = sigma_min
									snake_case__ :     Optional[int] 							=				denoised + z * (sigma_hat**2 - sigma_min**2) ** 0.5

									if not return_dict:
													return (prev_sample,)

									return CMStochasticIterativeSchedulerOutput(prev_sample=__UpperCamelCase		)




					def       __a      (       self   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	)					->  torch.FloatTensor:



									'''simple docstring'''







									snake_case__ :     Any 							=				self.sigmas.to(device=original_samples.device   ,	dtype=original_samples.dtype		)
									if original_samples.device.type == "mps" and torch.is_floating_point(__UpperCamelCase		):
													# mps does not support float64
													snake_case__ :     List[str] 							=				self.timesteps.to(original_samples.device   ,	dtype=torch.floataa		)
													snake_case__ :     Union[str, Any] 							=				timesteps.to(original_samples.device   ,	dtype=torch.floataa		)
									else:
													snake_case__ :     int 							=				self.timesteps.to(original_samples.device		)
													snake_case__ :     Any 							=				timesteps.to(original_samples.device		)

									snake_case__ :     Optional[Any] 							=				[(schedule_timesteps == t).nonzero().item() for t in timesteps]

									snake_case__ :     Optional[Any] 							=				sigmas[step_indices].flatten()
									while len(sigma.shape		) < len(original_samples.shape		):
													snake_case__ :     Tuple 							=				sigma.unsqueeze(-1		)

									snake_case__ :     Any 							=				original_samples + noise * sigma
									return noisy_samples




					def __len__(       self		)					->  Optional[Any]:



									'''simple docstring'''







									return self.config.num_train_timesteps



from __future__ import annotations

import unittest

from transformers import OpenAIGPTConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
				import tensorflow as tf

				from transformers.models.openai.modeling_tf_openai import (
				    TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFOpenAIGPTDoubleHeadsModel,
				    TFOpenAIGPTForSequenceClassification,
				    TFOpenAIGPTLMHeadModel,
				    TFOpenAIGPTModel,
				)





class 			__snake_case  :




					def __init__(       self   ,	__UpperCamelCase   ,	)					->  Tuple:



									'''simple docstring'''







									snake_case__ :     List[str] 							=				parent
									snake_case__ :     Optional[int] 							=				13
									snake_case__ :     Tuple 							=				7
									snake_case__ :     Optional[int] 							=				True
									snake_case__ :     int 							=				True
									snake_case__ :     int 							=				True
									snake_case__ :     int 							=				True
									snake_case__ :     Union[str, Any] 							=				True
									snake_case__ :     Optional[Any] 							=				99
									snake_case__ :     Dict 							=				32
									snake_case__ :     Union[str, Any] 							=				2
									snake_case__ :     Tuple 							=				4
									snake_case__ :     List[str] 							=				37
									snake_case__ :     Optional[int] 							=				'gelu'
									snake_case__ :     List[str] 							=				0.1
									snake_case__ :     Union[str, Any] 							=				0.1
									snake_case__ :     str 							=				512
									snake_case__ :     str 							=				16
									snake_case__ :     Dict 							=				2
									snake_case__ :     List[Any] 							=				0.0_2
									snake_case__ :     Union[str, Any] 							=				3
									snake_case__ :     Optional[Any] 							=				4
									snake_case__ :     List[Any] 							=				None
									snake_case__ :     Union[str, Any] 							=				self.vocab_size - 1




					def       __a      (       self		)					->  Dict:



									'''simple docstring'''







									snake_case__ :     Any 							=				ids_tensor([self.batch_size, self.seq_length]   ,	self.vocab_size		)

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

									snake_case__ :     List[str] 							=				None
									if self.use_token_type_ids:
													snake_case__ :     List[Any] 							=				ids_tensor([self.batch_size, self.seq_length]   ,	self.type_vocab_size		)

									snake_case__ :     Dict 							=				None
									if self.use_mc_token_ids:
													snake_case__ :     Any 							=				ids_tensor([self.batch_size, self.num_choices]   ,	self.seq_length		)

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

									snake_case__ :     str 							=				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__ :     Union[str, Any] 							=				ids_tensor([self.num_hidden_layers, self.num_attention_heads]   ,	2		)

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




					def       __a      (       self   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	*__UpperCamelCase		)					->  List[str]:



									'''simple docstring'''







									snake_case__ :     List[Any] 							=				TFOpenAIGPTModel(config=__UpperCamelCase		)
									snake_case__ :     str 							=				{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
									snake_case__ :     Dict 							=				model(__UpperCamelCase		)

									snake_case__ :     Tuple 							=				[input_ids, input_mask]
									snake_case__ :     List[str] 							=				model(__UpperCamelCase		)

									snake_case__ :     Tuple 							=				model(__UpperCamelCase		)

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




					def       __a      (       self   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	*__UpperCamelCase		)					->  Optional[int]:



									'''simple docstring'''







									snake_case__ :     List[str] 							=				TFOpenAIGPTLMHeadModel(config=__UpperCamelCase		)
									snake_case__ :     Optional[int] 							=				{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
									snake_case__ :     List[str] 							=				model(__UpperCamelCase		)
									self.parent.assertEqual(result.logits.shape   ,	(self.batch_size, self.seq_length, self.vocab_size)		)




					def       __a      (       self   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	*__UpperCamelCase		)					->  Tuple:



									'''simple docstring'''







									snake_case__ :     Dict 							=				TFOpenAIGPTDoubleHeadsModel(config=__UpperCamelCase		)

									snake_case__ :     Optional[int] 							=				tf.tile(tf.expand_dims(__UpperCamelCase   ,	1		)   ,	(1, self.num_choices, 1)		)
									snake_case__ :     Tuple 							=				tf.tile(tf.expand_dims(__UpperCamelCase   ,	1		)   ,	(1, self.num_choices, 1)		)
									snake_case__ :     Any 							=				tf.tile(tf.expand_dims(__UpperCamelCase   ,	1		)   ,	(1, self.num_choices, 1)		)

									snake_case__ :     Dict 							=				{
									    'input_ids': multiple_choice_inputs_ids,
									    'mc_token_ids': mc_token_ids,
									    'attention_mask': multiple_choice_input_mask,
									    'token_type_ids': multiple_choice_token_type_ids,
									}
									snake_case__ :     Tuple 							=				model(__UpperCamelCase		)
									self.parent.assertEqual(
									    result.logits.shape   ,	(self.batch_size, self.num_choices, self.seq_length, self.vocab_size)		)
									self.parent.assertEqual(result.mc_logits.shape   ,	(self.batch_size, self.num_choices)		)




					def       __a      (       self   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	*__UpperCamelCase		)					->  Tuple:



									'''simple docstring'''







									snake_case__ :     int 							=				self.num_labels
									snake_case__ :     int 							=				ids_tensor([self.batch_size]   ,	self.type_sequence_label_size		)
									snake_case__ :     str 							=				{
									    'input_ids': input_ids,
									    'attention_mask': input_mask,
									    'token_type_ids': token_type_ids,
									    'labels': sequence_labels,
									}
									snake_case__ :     str 							=				TFOpenAIGPTForSequenceClassification(__UpperCamelCase		)
									snake_case__ :     int 							=				model(__UpperCamelCase		)
									self.parent.assertEqual(result.logits.shape   ,	(self.batch_size, self.num_labels)		)




					def       __a      (       self		)					->  List[str]:



									'''simple docstring'''







									snake_case__ :     Dict 							=				self.prepare_config_and_inputs()

									(
									    (
									    snake_case__
									)							,  (
									    snake_case__
									)							,  (
									    snake_case__
									)							,  (
									    snake_case__
									)							,  (
									    snake_case__
									)							,  (
									    snake_case__
									)							,  (
									    snake_case__
									)							,  (
									    snake_case__
									)							,  (
									    snake_case__
									)							,  
									) :     Any 							=				config_and_inputs

									snake_case__ :     List[str] 							=				{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
									return config, inputs_dict





@require_tf
class 			__snake_case  (      _lowerCamelCase   ,_lowerCamelCase   ,unittest.TestCase     ):
					__lowerCamelCase	 =       (
					    (TFOpenAIGPTModel, TFOpenAIGPTLMHeadModel, TFOpenAIGPTDoubleHeadsModel, TFOpenAIGPTForSequenceClassification)
					    if is_tf_available()
					    else ()
					)
					__lowerCamelCase	 =       (
					    (TFOpenAIGPTLMHeadModel,) if is_tf_available() else ()
					)  # TODO (PVP): Add Double HeadsModel when generate() function is changed accordingly
					__lowerCamelCase	 =       (
					    {
					        """feature-extraction""": TFOpenAIGPTModel,
					        """text-classification""": TFOpenAIGPTForSequenceClassification,
					        """text-generation""": TFOpenAIGPTLMHeadModel,
					        """zero-shot""": TFOpenAIGPTForSequenceClassification,
					    }
					    if is_tf_available()
					    else {}
					)
					__lowerCamelCase	 =       False
					__lowerCamelCase	 =       False




					def       __a      (       self   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase   ,	__UpperCamelCase		)					->  int:



									'''simple docstring'''







									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       __a      (       self		)					->  Any:



									'''simple docstring'''







									snake_case__ :     Tuple 							=				TFOpenAIGPTModelTester(self		)
									snake_case__ :     Any 							=				ConfigTester(self   ,	config_class=__UpperCamelCase   ,	n_embd=37		)




					def       __a      (       self		)					->  int:



									'''simple docstring'''







									self.config_tester.run_common_tests()




					def       __a      (       self		)					->  Dict:



									'''simple docstring'''







									snake_case__ :     Optional[Any] 							=				self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_openai_gpt_model(*__UpperCamelCase		)




					def       __a      (       self		)					->  int:



									'''simple docstring'''







									snake_case__ :     str 							=				self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_openai_gpt_lm_head(*__UpperCamelCase		)




					def       __a      (       self		)					->  List[Any]:



									'''simple docstring'''







									snake_case__ :     Dict 							=				self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_openai_gpt_double_head(*__UpperCamelCase		)




					def       __a      (       self		)					->  Dict:



									'''simple docstring'''







									snake_case__ :     str 							=				self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_openai_gpt_for_sequence_classification(*__UpperCamelCase		)




					@slow
					def       __a      (       self		)					->  Union[str, Any]:



									'''simple docstring'''







									for model_name in TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
													snake_case__ :     Optional[Any] 							=				TFOpenAIGPTModel.from_pretrained(__UpperCamelCase		)
													self.assertIsNotNone(__UpperCamelCase		)





@require_tf
class 			__snake_case  (      unittest.TestCase     ):




					@slow
					def       __a      (       self		)					->  Union[str, Any]:



									'''simple docstring'''







									snake_case__ :     Dict 							=				TFOpenAIGPTLMHeadModel.from_pretrained('openai-gpt'		)
									snake_case__ :     Any 							=				tf.convert_to_tensor([[481, 4735, 544]]   ,	dtype=tf.intaa		)  # the president is
									snake_case__ :     int 							=				[
									    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__ :     int 							=				model.generate(__UpperCamelCase   ,	do_sample=__UpperCamelCase		)
									self.assertListEqual(output_ids[0].numpy().tolist()   ,	__UpperCamelCase		)


