'''simple docstring'''
import itertools
from dataclasses import dataclass
from io import StringIO
from typing import Optional

import pyarrow as pa

import datasets
from datasets.features.features import require_storage_cast
from datasets.table import table_cast


a=	datasets.utils.logging.get_logger(__name__)






@dataclass
class       __lowercase		(    datasets.BuilderConfig    ):







     """simple docstring"""






     SCREAMING_SNAKE_CASE__		 =    None
     SCREAMING_SNAKE_CASE__		 =    "utf-8"
     SCREAMING_SNAKE_CASE__		 =    None
     SCREAMING_SNAKE_CASE__		 =    10 << 20  # 10MB
     SCREAMING_SNAKE_CASE__		 =    False
     SCREAMING_SNAKE_CASE__		 =    "line"






class       __lowercase		(    datasets.ArrowBasedBuilder    ):







     """simple docstring"""






     SCREAMING_SNAKE_CASE__		 =    TextConfig







     def lowerCAmelCase  (		self     ):
         return datasets.DatasetInfo(features=self.config.features     )







     def lowerCAmelCase  (		self  ,      _lowerCamelCase     ):
         if not self.config.data_files:
             raise ValueError(f"""At least one data file must be specified, but got data_files={self.config.data_files}"""     )
         __UpperCamelCase						:						Any		     =	dl_manager.download_and_extract(self.config.data_files     )
         if isinstance(_lowerCamelCase  ,      (str, list, tuple)     ):
             __UpperCamelCase						:						Optional[Any]		     =	data_files
             if isinstance(_lowerCamelCase  ,      _lowerCamelCase     ):
                 __UpperCamelCase						:						str		     =	[files]
             __UpperCamelCase						:						List[str]		     =	[dl_manager.iter_files(_lowerCamelCase     ) for file in files]
             return [datasets.SplitGenerator(name=datasets.Split.TRAIN  ,      gen_kwargs={'files': files}     )]
         __UpperCamelCase						:						Tuple		     =	[]
         for split_name, files in data_files.items():
             if isinstance(_lowerCamelCase  ,      _lowerCamelCase     ):
                 __UpperCamelCase						:						str		     =	[files]
             __UpperCamelCase						:						Optional[int]		     =	[dl_manager.iter_files(_lowerCamelCase     ) for file in files]
             splits.append(datasets.SplitGenerator(name=_lowerCamelCase  ,      gen_kwargs={'files': files}     )     )
         return splits







     def lowerCAmelCase  (		self  ,      _lowerCamelCase     ):
         if self.config.features is not None:
             __UpperCamelCase						:						int		     =	self.config.features.arrow_schema
             if all(not require_storage_cast(_lowerCamelCase     ) for feature in self.config.features.values()     ):
                 # cheaper cast
                 __UpperCamelCase						:						str		     =	pa_table.cast(_lowerCamelCase     )
             else:
                 # more expensive cast; allows str <-> int/float or str to Audio for example
                 __UpperCamelCase						:						str		     =	table_cast(_lowerCamelCase  ,      _lowerCamelCase     )
             return pa_table
         else:
             return pa_table.cast(pa.schema({'text': pa.string()}     )     )







     def lowerCAmelCase  (		self  ,      _lowerCamelCase     ):
         __UpperCamelCase						:						Any		     =	list(self.config.features     ) if self.config.features is not None else ['text']
         for file_idx, file in enumerate(itertools.chain.from_iterable(_lowerCamelCase     )     ):
             # open in text mode, by default translates universal newlines ("\n", "\r\n" and "\r") into "\n"
             with open(_lowerCamelCase  ,      encoding=self.config.encoding  ,      errors=self.config.errors     ) as f:
                 if self.config.sample_by == "line":
                     __UpperCamelCase						:						Any		     =	0
                     while True:
                         __UpperCamelCase						:						Union[str, Any]		     =	f.read(self.config.chunksize     )
                         if not batch:
                             break
                         batch += f.readline()  # finish current line
                         # StringIO.readlines, by default splits only on "\n" (and keeps line breaks)
                         __UpperCamelCase						:						Tuple		     =	StringIO(_lowerCamelCase     ).readlines()
                         if not self.config.keep_linebreaks:
                             __UpperCamelCase						:						Union[str, Any]		     =	[line.rstrip('\n'     ) for line in batch]
                         __UpperCamelCase						:						List[str]		     =	pa.Table.from_arrays([pa.array(_lowerCamelCase     )]  ,      names=_lowerCamelCase     )
                         # Uncomment for debugging (will print the Arrow table size and elements)
                         # logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
                         # logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
                         yield (file_idx, batch_idx), self._cast_table(_lowerCamelCase     )
                         batch_idx += 1
                 elif self.config.sample_by == "paragraph":
                     __UpperCamelCase						:						Optional[Any]		     =	0
                     __UpperCamelCase						:						Dict		     =	''
                     while True:
                         __UpperCamelCase						:						int		     =	f.read(self.config.chunksize     )
                         if not new_batch:
                             break
                         batch += new_batch
                         batch += f.readline()  # finish current line
                         __UpperCamelCase						:						str		     =	batch.split('\n\n'     )
                         __UpperCamelCase						:						Optional[int]		     =	pa.Table.from_arrays(
                             [pa.array([example for example in batch[:-1] if example]     )]  ,      names=_lowerCamelCase     )
                         # Uncomment for debugging (will print the Arrow table size and elements)
                         # logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
                         # logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
                         yield (file_idx, batch_idx), self._cast_table(_lowerCamelCase     )
                         batch_idx += 1
                         __UpperCamelCase						:						Optional[Any]		     =	batch[-1]
                     if batch:
                         __UpperCamelCase						:						Any		     =	pa.Table.from_arrays([pa.array([batch]     )]  ,      names=_lowerCamelCase     )
                         yield (file_idx, batch_idx), self._cast_table(_lowerCamelCase     )
                 elif self.config.sample_by == "document":
                     __UpperCamelCase						:						List[Any]		     =	f.read()
                     __UpperCamelCase						:						str		     =	pa.Table.from_arrays([pa.array([text]     )]  ,      names=_lowerCamelCase     )
                     yield file_idx, self._cast_table(_lowerCamelCase     )




'''simple docstring'''
import tempfile
import unittest

import numpy as np

import transformers
from transformers import GPTaConfig, GPTaTokenizer, is_flax_available, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_flax, slow

from ...generation.test_flax_utils import FlaxGenerationTesterMixin
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
  import jax
  import jax.numpy as jnp

  from transformers.modeling_flax_pytorch_utils import (
      convert_pytorch_state_dict_to_flax,
      load_flax_weights_in_pytorch_model,
  )
  from transformers.models.gpta.modeling_flax_gpta import FlaxGPTaLMHeadModel, FlaxGPTaModel

if is_torch_available():
  import torch






class       __lowercase		:







     """simple docstring"""






     def __init__(		self  ,      _lowerCamelCase  ,      _lowerCamelCase=1_4  ,      _lowerCamelCase=7  ,      _lowerCamelCase=True  ,      _lowerCamelCase=True  ,      _lowerCamelCase=False  ,      _lowerCamelCase=True  ,      _lowerCamelCase=9_9  ,      _lowerCamelCase=3_2  ,      _lowerCamelCase=5  ,      _lowerCamelCase=4  ,      _lowerCamelCase=3_7  ,      _lowerCamelCase="gelu"  ,      _lowerCamelCase=0.1  ,      _lowerCamelCase=0.1  ,      _lowerCamelCase=5_1_2  ,      _lowerCamelCase=0.0_2  ,      ):
         __UpperCamelCase						:						int		     =	parent
         __UpperCamelCase						:						Union[str, Any]		     =	batch_size
         __UpperCamelCase						:						Tuple		     =	seq_length
         __UpperCamelCase						:						Tuple		     =	is_training
         __UpperCamelCase						:						str		     =	use_input_mask
         __UpperCamelCase						:						int		     =	use_token_type_ids
         __UpperCamelCase						:						List[Any]		     =	use_labels
         __UpperCamelCase						:						Tuple		     =	vocab_size
         __UpperCamelCase						:						Any		     =	hidden_size
         __UpperCamelCase						:						int		     =	num_hidden_layers
         __UpperCamelCase						:						List[Any]		     =	num_attention_heads
         __UpperCamelCase						:						str		     =	intermediate_size
         __UpperCamelCase						:						Any		     =	hidden_act
         __UpperCamelCase						:						Tuple		     =	hidden_dropout_prob
         __UpperCamelCase						:						Any		     =	attention_probs_dropout_prob
         __UpperCamelCase						:						Union[str, Any]		     =	max_position_embeddings
         __UpperCamelCase						:						Optional[int]		     =	initializer_range
         __UpperCamelCase						:						str		     =	None
         __UpperCamelCase						:						Dict		     =	vocab_size - 1
         __UpperCamelCase						:						Tuple		     =	vocab_size - 1
         __UpperCamelCase						:						int		     =	vocab_size - 1







     def lowerCAmelCase  (		self     ):
         __UpperCamelCase						:						Optional[Any]		     =	ids_tensor([self.batch_size, self.seq_length]  ,      self.vocab_size     )

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

         __UpperCamelCase						:						Optional[Any]		     =	GPTaConfig(
             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  ,      use_cache=_lowerCamelCase  ,      bos_token_id=self.bos_token_id  ,      eos_token_id=self.eos_token_id  ,      pad_token_id=self.pad_token_id  ,      )

         return (config, input_ids, input_mask)







     def lowerCAmelCase  (		self     ):
         __UpperCamelCase						:						Union[str, Any]		     =	self.prepare_config_and_inputs()
         __UpperCamelCase     ,       __UpperCamelCase     ,       __UpperCamelCase						:						Optional[Any]		     =	config_and_inputs
         __UpperCamelCase						:						Optional[Any]		     =	{'input_ids': input_ids, 'attention_mask': attention_mask}
         return config, inputs_dict







     def lowerCAmelCase  (		self     ):
         __UpperCamelCase     ,       __UpperCamelCase     ,       __UpperCamelCase						:						Optional[int]		     =	self.prepare_config_and_inputs()

         __UpperCamelCase						:						Optional[Any]		     =	floats_tensor([self.batch_size, self.seq_length, self.hidden_size]     )
         __UpperCamelCase						:						List[Any]		     =	ids_tensor([self.batch_size, self.seq_length]  ,      vocab_size=2     )

         return (
             config,
             input_ids,
             attention_mask,
             encoder_hidden_states,
             encoder_attention_mask,
         )







     def lowerCAmelCase  (		self  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase     ):
         __UpperCamelCase						:						str		     =	2_0
         __UpperCamelCase						:						List[Any]		     =	model_class_name(_lowerCamelCase     )

         __UpperCamelCase						:						Optional[int]		     =	model.init_cache(input_ids.shape[0]  ,      _lowerCamelCase     )
         __UpperCamelCase						:						Union[str, Any]		     =	jnp.ones((input_ids.shape[0], max_decoder_length)  ,      dtype='i4'     )

         __UpperCamelCase						:						List[str]		     =	jnp.broadcast_to(
             jnp.arange(input_ids.shape[-1] - 1     )[None, :]  ,      (input_ids.shape[0], input_ids.shape[-1] - 1)     )
         __UpperCamelCase						:						List[Any]		     =	model(
             input_ids[:, :-1]  ,      attention_mask=_lowerCamelCase  ,      past_key_values=_lowerCamelCase  ,      position_ids=_lowerCamelCase  ,      )

         __UpperCamelCase						:						int		     =	jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]  ,      dtype='i4'     )
         __UpperCamelCase						:						Tuple		     =	model(
             input_ids[:, -1:]  ,      attention_mask=_lowerCamelCase  ,      past_key_values=outputs_cache.past_key_values  ,      position_ids=_lowerCamelCase  ,      )

         __UpperCamelCase						:						List[str]		     =	model(_lowerCamelCase     )

         __UpperCamelCase						:						Optional[int]		     =	np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])     )     )
         self.parent.assertTrue(diff < 1E-3  ,      msg=f"""Max diff is {diff}"""     )







     def lowerCAmelCase  (		self  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase     ):
         __UpperCamelCase						:						Optional[Any]		     =	2_0
         __UpperCamelCase						:						Any		     =	model_class_name(_lowerCamelCase     )

         __UpperCamelCase						:						Union[str, Any]		     =	jnp.concatenate(
             [attention_mask, jnp.zeros((attention_mask.shape[0], max_decoder_length - attention_mask.shape[1])     )]  ,      axis=-1  ,      )

         __UpperCamelCase						:						Any		     =	model.init_cache(input_ids.shape[0]  ,      _lowerCamelCase     )
         __UpperCamelCase						:						Optional[Any]		     =	jnp.broadcast_to(
             jnp.arange(input_ids.shape[-1] - 1     )[None, :]  ,      (input_ids.shape[0], input_ids.shape[-1] - 1)     )

         __UpperCamelCase						:						List[Any]		     =	model(
             input_ids[:, :-1]  ,      attention_mask=_lowerCamelCase  ,      past_key_values=_lowerCamelCase  ,      position_ids=_lowerCamelCase  ,      )
         __UpperCamelCase						:						Any		     =	jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]  ,      dtype='i4'     )
         __UpperCamelCase						:						Dict		     =	model(
             input_ids[:, -1:]  ,      past_key_values=outputs_cache.past_key_values  ,      attention_mask=_lowerCamelCase  ,      position_ids=_lowerCamelCase  ,      )

         __UpperCamelCase						:						Optional[Any]		     =	model(_lowerCamelCase  ,      attention_mask=_lowerCamelCase     )

         __UpperCamelCase						:						Any		     =	np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])     )     )
         self.parent.assertTrue(diff < 1E-3  ,      msg=f"""Max diff is {diff}"""     )






@require_flax
class       __lowercase		(    _lowerCamelCase      ,				_lowerCamelCase      ,				unittest.TestCase    ):







     """simple docstring"""






     SCREAMING_SNAKE_CASE__		 =    (FlaxGPTaModel, FlaxGPTaLMHeadModel) if is_flax_available() else ()
     SCREAMING_SNAKE_CASE__		 =    (FlaxGPTaLMHeadModel,) if is_flax_available() else ()







     def lowerCAmelCase  (		self     ):
         __UpperCamelCase						:						Optional[int]		     =	FlaxGPTaModelTester(self     )







     def lowerCAmelCase  (		self     ):
         for model_class_name in self.all_model_classes:
             __UpperCamelCase     ,       __UpperCamelCase     ,       __UpperCamelCase						:						Union[str, Any]		     =	self.model_tester.prepare_config_and_inputs()
             self.model_tester.check_use_cache_forward(_lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase     )







     def lowerCAmelCase  (		self     ):
         for model_class_name in self.all_model_classes:
             __UpperCamelCase     ,       __UpperCamelCase     ,       __UpperCamelCase						:						Optional[int]		     =	self.model_tester.prepare_config_and_inputs()
             self.model_tester.check_use_cache_forward_with_attn_mask(
                 _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase     )







     @slow
     def lowerCAmelCase  (		self     ):
         __UpperCamelCase						:						Optional[int]		     =	GPTaTokenizer.from_pretrained('gpt2'  ,      pad_token='</s>'  ,      padding_side='left'     )
         __UpperCamelCase						:						str		     =	tokenizer(['Hello this is a long string', 'Hey']  ,      return_tensors='np'  ,      padding=_lowerCamelCase  ,      truncation=_lowerCamelCase     )

         __UpperCamelCase						:						int		     =	FlaxGPTaLMHeadModel.from_pretrained('gpt2'     )
         __UpperCamelCase						:						Union[str, Any]		     =	False
         __UpperCamelCase						:						Optional[Any]		     =	model.config.eos_token_id

         __UpperCamelCase						:						List[str]		     =	jax.jit(model.generate     )

         __UpperCamelCase						:						List[str]		     =	jit_generate(inputs['input_ids']  ,      attention_mask=inputs['attention_mask']     ).sequences

         __UpperCamelCase						:						Optional[int]		     =	tokenizer.batch_decode(_lowerCamelCase  ,      skip_special_tokens=_lowerCamelCase     )

         __UpperCamelCase						:						Dict		     =	[
             'Hello this is a long string of words. I\'m going to start with the first one.\n',
             'Hey, I\'m not sure if I\'m going to be able to do',
         ]

         self.assertListEqual(_lowerCamelCase  ,      _lowerCamelCase     )







     @is_pt_flax_cross_test
     def lowerCAmelCase  (		self     ):
         __UpperCamelCase     ,       __UpperCamelCase						:						Optional[int]		     =	self.model_tester.prepare_config_and_inputs_for_common()

         for model_class in self.all_model_classes:
             with self.subTest(model_class.__name__     ):
                 # prepare inputs
                 __UpperCamelCase						:						Tuple		     =	self._prepare_for_class(_lowerCamelCase  ,      _lowerCamelCase     )
                 __UpperCamelCase						:						Dict		     =	{k: torch.tensor(v.tolist()     ) for k, v in prepared_inputs_dict.items()}

                 # load corresponding PyTorch class
                 __UpperCamelCase						:						Union[str, Any]		     =	model_class.__name__[4:]  # Skip the "Flax" at the beginning
                 __UpperCamelCase						:						List[str]		     =	getattr(_lowerCamelCase  ,      _lowerCamelCase     )

                 __UpperCamelCase     ,       __UpperCamelCase						:						Tuple		     =	pt_inputs['input_ids'].shape
                 __UpperCamelCase						:						int		     =	np.random.randint(0  ,      seq_length - 1  ,      size=(batch_size,)     )
                 for batch_idx, start_index in enumerate(_lowerCamelCase     ):
                     __UpperCamelCase						:						int		     =	0
                     __UpperCamelCase						:						Tuple		     =	1
                     __UpperCamelCase						:						Optional[int]		     =	0
                     __UpperCamelCase						:						List[Any]		     =	1
                 __UpperCamelCase						:						str		     =	pt_model_class(_lowerCamelCase     ).eval()
                 __UpperCamelCase						:						Union[str, Any]		     =	model_class(_lowerCamelCase  ,      dtype=jnp.floataa     )

                 __UpperCamelCase						:						Optional[int]		     =	convert_pytorch_state_dict_to_flax(pt_model.state_dict()  ,      _lowerCamelCase     )
                 __UpperCamelCase						:						List[str]		     =	fx_state

                 with torch.no_grad():
                     __UpperCamelCase						:						List[Any]		     =	pt_model(**_lowerCamelCase     ).to_tuple()

                 __UpperCamelCase						:						str		     =	fx_model(**_lowerCamelCase     ).to_tuple()
                 self.assertEqual(len(_lowerCamelCase     )  ,      len(_lowerCamelCase     )  ,      'Output lengths differ between Flax and PyTorch'     )
                 for fx_output, pt_output in zip(_lowerCamelCase  ,      _lowerCamelCase     ):
                     self.assert_almost_equals(fx_output[:, -1]  ,      pt_output[:, -1].numpy()  ,      4E-2     )

                 with tempfile.TemporaryDirectory() as tmpdirname:
                     pt_model.save_pretrained(_lowerCamelCase     )
                     __UpperCamelCase						:						Any		     =	model_class.from_pretrained(_lowerCamelCase  ,      from_pt=_lowerCamelCase     )

                 __UpperCamelCase						:						Union[str, Any]		     =	fx_model_loaded(**_lowerCamelCase     ).to_tuple()
                 self.assertEqual(
                     len(_lowerCamelCase     )  ,      len(_lowerCamelCase     )  ,      'Output lengths differ between Flax and PyTorch'     )
                 for fx_output_loaded, pt_output in zip(_lowerCamelCase  ,      _lowerCamelCase     ):
                     self.assert_almost_equals(fx_output_loaded[:, -1]  ,      pt_output[:, -1].numpy()  ,      4E-2     )







     @is_pt_flax_cross_test
     def lowerCAmelCase  (		self     ):
         __UpperCamelCase     ,       __UpperCamelCase						:						Optional[Any]		     =	self.model_tester.prepare_config_and_inputs_for_common()
         for model_class in self.all_model_classes:
             with self.subTest(model_class.__name__     ):
                 # prepare inputs
                 __UpperCamelCase						:						Tuple		     =	self._prepare_for_class(_lowerCamelCase  ,      _lowerCamelCase     )
                 __UpperCamelCase						:						int		     =	{k: torch.tensor(v.tolist()     ) for k, v in prepared_inputs_dict.items()}

                 # load corresponding PyTorch class
                 __UpperCamelCase						:						Optional[Any]		     =	model_class.__name__[4:]  # Skip the "Flax" at the beginning
                 __UpperCamelCase						:						int		     =	getattr(_lowerCamelCase  ,      _lowerCamelCase     )

                 __UpperCamelCase						:						Optional[Any]		     =	pt_model_class(_lowerCamelCase     ).eval()
                 __UpperCamelCase						:						List[Any]		     =	model_class(_lowerCamelCase  ,      dtype=jnp.floataa     )

                 __UpperCamelCase						:						str		     =	load_flax_weights_in_pytorch_model(_lowerCamelCase  ,      fx_model.params     )
                 __UpperCamelCase     ,       __UpperCamelCase						:						int		     =	pt_inputs['input_ids'].shape
                 __UpperCamelCase						:						Dict		     =	np.random.randint(0  ,      seq_length - 1  ,      size=(batch_size,)     )
                 for batch_idx, start_index in enumerate(_lowerCamelCase     ):
                     __UpperCamelCase						:						Union[str, Any]		     =	0
                     __UpperCamelCase						:						List[str]		     =	1
                     __UpperCamelCase						:						Optional[int]		     =	0
                     __UpperCamelCase						:						Optional[int]		     =	1

                 # make sure weights are tied in PyTorch
                 pt_model.tie_weights()

                 with torch.no_grad():
                     __UpperCamelCase						:						Any		     =	pt_model(**_lowerCamelCase     ).to_tuple()

                 __UpperCamelCase						:						Optional[Any]		     =	fx_model(**_lowerCamelCase     ).to_tuple()
                 self.assertEqual(len(_lowerCamelCase     )  ,      len(_lowerCamelCase     )  ,      'Output lengths differ between Flax and PyTorch'     )
                 for fx_output, pt_output in zip(_lowerCamelCase  ,      _lowerCamelCase     ):
                     self.assert_almost_equals(fx_output[:, -1]  ,      pt_output[:, -1].numpy()  ,      4E-2     )

                 with tempfile.TemporaryDirectory() as tmpdirname:
                     fx_model.save_pretrained(_lowerCamelCase     )
                     __UpperCamelCase						:						int		     =	pt_model_class.from_pretrained(_lowerCamelCase  ,      from_flax=_lowerCamelCase     )

                 with torch.no_grad():
                     __UpperCamelCase						:						Dict		     =	pt_model_loaded(**_lowerCamelCase     ).to_tuple()

                 self.assertEqual(
                     len(_lowerCamelCase     )  ,      len(_lowerCamelCase     )  ,      'Output lengths differ between Flax and PyTorch'     )
                 for fx_output, pt_output in zip(_lowerCamelCase  ,      _lowerCamelCase     ):
                     self.assert_almost_equals(fx_output[:, -1]  ,      pt_output[:, -1].numpy()  ,      4E-2     )







     @slow
     def lowerCAmelCase  (		self     ):
         for model_class_name in self.all_model_classes:
             __UpperCamelCase						:						Union[str, Any]		     =	model_class_name.from_pretrained('gpt2'  ,      from_pt=_lowerCamelCase     )
             __UpperCamelCase						:						List[str]		     =	model(np.ones((1, 1)     )     )
             self.assertIsNotNone(_lowerCamelCase     )



