




'''simple docstring'''


import itertools
import json
import os
import unittest

from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast
from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin

@require_tokenizers
class       A   (		_a					,unittest.TestCase   ):
							lowercase_          =    RobertaTokenizer
							lowercase_          =    RobertaTokenizerFast
							lowercase_          =    True
							lowercase_          =    {'cls_token': '<s>'}







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


														"""simple docstring"""


														super().setUp()

														# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
														_a     					=    [
														    '''l''',
														    '''o''',
														    '''w''',
														    '''e''',
														    '''r''',
														    '''s''',
														    '''t''',
														    '''i''',
														    '''d''',
														    '''n''',
														    '''\u0120''',
														    '''\u0120l''',
														    '''\u0120n''',
														    '''\u0120lo''',
														    '''\u0120low''',
														    '''er''',
														    '''\u0120lowest''',
														    '''\u0120newer''',
														    '''\u0120wider''',
														    '''<unk>''',
														]
														_a     					=    dict(zip(lowerCAmelCase_							,      range(len(lowerCAmelCase_ ) ) ) )
														_a     					=    ['''#version: 0.2''', '''\u0120 l''', '''\u0120l o''', '''\u0120lo w''', '''e r''', '''''']
														_a     					=    {'''unk_token''': '''<unk>'''}

														_a     					=    os.path.join(self.tmpdirname							,      VOCAB_FILES_NAMES['''vocab_file'''] )
														_a     					=    os.path.join(self.tmpdirname							,      VOCAB_FILES_NAMES['''merges_file'''] )
														with open(self.vocab_file							,      '''w'''							,      encoding='''utf-8''' ) as fp:
																					fp.write(json.dumps(lowerCAmelCase_ ) + '''\n''' )
														with open(self.merges_file							,      '''w'''							,      encoding='''utf-8''' ) as fp:
																					fp.write('''\n'''.join(lowerCAmelCase_ ) )







							def        __lowerCAmelCase      (  self	:  Optional[Any]							,      **lowerCAmelCase_	:  List[Any] )      ->							int:


														"""simple docstring"""


														kwargs.update(self.special_tokens_map )
														return self.tokenizer_class.from_pretrained(self.tmpdirname							,      **lowerCAmelCase_ )







							def        __lowerCAmelCase      (  self	:  List[str]							,      **lowerCAmelCase_	:  int )      ->							Optional[int]:


														"""simple docstring"""


														kwargs.update(self.special_tokens_map )
														return RobertaTokenizerFast.from_pretrained(self.tmpdirname							,      **lowerCAmelCase_ )







							def        __lowerCAmelCase      (  self	:  str							,      lowerCAmelCase_	:  List[str] )      ->							Dict:


														"""simple docstring"""


														_a     					=    '''lower newer'''
														_a     					=    '''lower newer'''
														return input_text, output_text







							def        __lowerCAmelCase      (  self	:  Union[str, Any] )      ->							List[Any]:


														"""simple docstring"""


														_a     					=    self.tokenizer_class(self.vocab_file							,      self.merges_file							,      **self.special_tokens_map )
														_a     					=    '''lower newer'''
														_a     					=    ['''l''', '''o''', '''w''', '''er''', '''\u0120''', '''n''', '''e''', '''w''', '''er''']
														_a     					=    tokenizer.tokenize(lowerCAmelCase_ )  # , add_prefix_space=True)
														self.assertListEqual(lowerCAmelCase_							,      lowerCAmelCase_ )

														_a     					=    tokens + [tokenizer.unk_token]
														_a     					=    [0, 1, 2, 15, 10, 9, 3, 2, 15, 19]
														self.assertListEqual(tokenizer.convert_tokens_to_ids(lowerCAmelCase_ )							,      lowerCAmelCase_ )







							def        __lowerCAmelCase      (  self	:  List[str] )      ->							int:


														"""simple docstring"""


														_a     					=    self.get_tokenizer()

														self.assertListEqual(tokenizer.encode('''Hello world!'''							,      add_special_tokens=lowerCAmelCase_ )							,      [0, 3_14_14, 2_32, 3_28, 2] )
														self.assertListEqual(
														    tokenizer.encode('''Hello world! cécé herlolip 418'''							,      add_special_tokens=lowerCAmelCase_ )							,      [0, 3_14_14, 2_32, 3_28, 7_40, 11_40, 1_26_95, 69, 4_60_78, 15_88, 2]							,      )







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


														"""simple docstring"""


														_a     					=    self.tokenizer_class.from_pretrained('''roberta-base''' )

														_a     					=    tokenizer.encode('''sequence builders'''							,      add_special_tokens=lowerCAmelCase_ )
														_a     					=    tokenizer.encode('''multi-sequence build'''							,      add_special_tokens=lowerCAmelCase_ )

														_a     					=    tokenizer.encode(
														    '''sequence builders'''							,      add_special_tokens=lowerCAmelCase_							,      add_prefix_space=lowerCAmelCase_ )
														_a     					=    tokenizer.encode(
														    '''sequence builders'''							,      '''multi-sequence build'''							,      add_special_tokens=lowerCAmelCase_							,      add_prefix_space=lowerCAmelCase_ )

														_a     					=    tokenizer.build_inputs_with_special_tokens(lowerCAmelCase_ )
														_a     					=    tokenizer.build_inputs_with_special_tokens(lowerCAmelCase_							,      lowerCAmelCase_ )

														assert encoded_sentence == encoded_text_from_decode
														assert encoded_pair == encoded_pair_from_decode







							def        __lowerCAmelCase      (  self	:  List[Any] )      ->							str:


														"""simple docstring"""


														_a     					=    self.get_tokenizer()

														_a     					=    '''Encode this sequence.'''
														_a     					=    tokenizer.byte_encoder[''' '''.encode('''utf-8''' )[0]]

														# Testing encoder arguments
														_a     					=    tokenizer.encode(lowerCAmelCase_							,      add_special_tokens=lowerCAmelCase_							,      add_prefix_space=lowerCAmelCase_ )
														_a     					=    tokenizer.convert_ids_to_tokens(encoded[0] )[0]
														self.assertNotEqual(lowerCAmelCase_							,      lowerCAmelCase_ )

														_a     					=    tokenizer.encode(lowerCAmelCase_							,      add_special_tokens=lowerCAmelCase_							,      add_prefix_space=lowerCAmelCase_ )
														_a     					=    tokenizer.convert_ids_to_tokens(encoded[0] )[0]
														self.assertEqual(lowerCAmelCase_							,      lowerCAmelCase_ )

														tokenizer.add_special_tokens({'''bos_token''': '''<s>'''} )
														_a     					=    tokenizer.encode(lowerCAmelCase_							,      add_special_tokens=lowerCAmelCase_ )
														_a     					=    tokenizer.convert_ids_to_tokens(encoded[1] )[0]
														self.assertNotEqual(lowerCAmelCase_							,      lowerCAmelCase_ )

														# Testing spaces after special tokens
														_a     					=    '''<mask>'''
														tokenizer.add_special_tokens(
														    {'''mask_token''': AddedToken(lowerCAmelCase_							,      lstrip=lowerCAmelCase_							,      rstrip=lowerCAmelCase_ )} )  # mask token has a left space
														_a     					=    tokenizer.convert_tokens_to_ids(lowerCAmelCase_ )

														_a     					=    '''Encode <mask> sequence'''
														_a     					=    '''Encode <mask>sequence'''

														_a     					=    tokenizer.encode(lowerCAmelCase_ )
														_a     					=    encoded.index(lowerCAmelCase_ )
														_a     					=    tokenizer.convert_ids_to_tokens(encoded[mask_loc + 1] )[0]
														self.assertEqual(lowerCAmelCase_							,      lowerCAmelCase_ )

														_a     					=    tokenizer.encode(lowerCAmelCase_ )
														_a     					=    encoded.index(lowerCAmelCase_ )
														_a     					=    tokenizer.convert_ids_to_tokens(encoded[mask_loc + 1] )[0]
														self.assertNotEqual(lowerCAmelCase_							,      lowerCAmelCase_ )







							def        __lowerCAmelCase      (  self	:  Optional[int] )      ->							Any:


														"""simple docstring"""


														pass







							def        __lowerCAmelCase      (  self	:  Tuple )      ->							Dict:


														"""simple docstring"""


														for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
																					with self.subTest(F'{tokenizer.__class__.__name__} ({pretrained_name})' ):
																												_a     					=    self.rust_tokenizer_class.from_pretrained(lowerCAmelCase_							,      **lowerCAmelCase_ )
																												_a     					=    self.tokenizer_class.from_pretrained(lowerCAmelCase_							,      **lowerCAmelCase_ )
																												_a     					=    '''A, <mask> AllenNLP sentence.'''
																												_a     					=    tokenizer_r.encode_plus(lowerCAmelCase_							,      add_special_tokens=lowerCAmelCase_							,      return_token_type_ids=lowerCAmelCase_ )
																												_a     					=    tokenizer_p.encode_plus(lowerCAmelCase_							,      add_special_tokens=lowerCAmelCase_							,      return_token_type_ids=lowerCAmelCase_ )

																												# token_type_ids should put 0 everywhere
																												self.assertEqual(sum(tokens_r['''token_type_ids'''] )							,      sum(tokens_p['''token_type_ids'''] ) )

																												# attention_mask should put 1 everywhere, so sum over length should be 1
																												self.assertEqual(
																												    sum(tokens_r['''attention_mask'''] ) / len(tokens_r['''attention_mask'''] )							,      sum(tokens_p['''attention_mask'''] ) / len(tokens_p['''attention_mask'''] )							,      )

																												_a     					=    tokenizer_r.convert_ids_to_tokens(tokens_r['''input_ids'''] )
																												_a     					=    tokenizer_p.convert_ids_to_tokens(tokens_p['''input_ids'''] )

																												# Rust correctly handles the space before the mask while python doesnt
																												self.assertSequenceEqual(tokens_p['''input_ids''']							,      [0, 2_50, 6, 5_02_64, 38_23, 4_87, 2_19_92, 36_45, 4, 2] )
																												self.assertSequenceEqual(tokens_r['''input_ids''']							,      [0, 2_50, 6, 5_02_64, 38_23, 4_87, 2_19_92, 36_45, 4, 2] )

																												self.assertSequenceEqual(
																												    lowerCAmelCase_							,      ['''<s>''', '''A''', ''',''', '''<mask>''', '''ĠAllen''', '''N''', '''LP''', '''Ġsentence''', '''.''', '''</s>'''] )
																												self.assertSequenceEqual(
																												    lowerCAmelCase_							,      ['''<s>''', '''A''', ''',''', '''<mask>''', '''ĠAllen''', '''N''', '''LP''', '''Ġsentence''', '''.''', '''</s>'''] )







							def        __lowerCAmelCase      (  self	:  List[str] )      ->							List[Any]:


														"""simple docstring"""


														for trim_offsets, add_prefix_space in itertools.product([True, False]							,      repeat=2 ):
																					_a     					=    self.rust_tokenizer_class.from_pretrained(
																					    self.tmpdirname							,      use_fast=lowerCAmelCase_							,      add_prefix_space=lowerCAmelCase_							,      trim_offsets=lowerCAmelCase_ )

																					_a     					=    json.loads(tokenizer_r.backend_tokenizer.pre_tokenizer.__getstate__() )
																					_a     					=    json.loads(tokenizer_r.backend_tokenizer.post_processor.__getstate__() )

																					self.assertEqual(pre_tokenizer_state['''add_prefix_space''']							,      lowerCAmelCase_ )

																					self.assertEqual(post_processor_state['''add_prefix_space''']							,      lowerCAmelCase_ )
																					self.assertEqual(post_processor_state['''trim_offsets''']							,      lowerCAmelCase_ )







							def        __lowerCAmelCase      (  self	:  Optional[int] )      ->							Optional[Any]:


														"""simple docstring"""


														for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
																					with self.subTest(F'{tokenizer.__class__.__name__} ({pretrained_name})' ):
																												_a     					=    '''hello'''  # `hello` is a token in the vocabulary of `pretrained_name`
																												_a     					=    F'{text_of_1_token} {text_of_1_token}'

																												_a     					=    self.rust_tokenizer_class.from_pretrained(
																												    lowerCAmelCase_							,      use_fast=lowerCAmelCase_							,      add_prefix_space=lowerCAmelCase_							,      trim_offsets=lowerCAmelCase_ )
																												_a     					=    tokenizer_r(lowerCAmelCase_							,      return_offsets_mapping=lowerCAmelCase_							,      add_special_tokens=lowerCAmelCase_ )
																												self.assertEqual(encoding.offset_mapping[0]							,      (0, len(lowerCAmelCase_ )) )
																												self.assertEqual(
																												    encoding.offset_mapping[1]							,      (len(lowerCAmelCase_ ) + 1, len(lowerCAmelCase_ ) + 1 + len(lowerCAmelCase_ ))							,      )

																												_a     					=    self.rust_tokenizer_class.from_pretrained(
																												    lowerCAmelCase_							,      use_fast=lowerCAmelCase_							,      add_prefix_space=lowerCAmelCase_							,      trim_offsets=lowerCAmelCase_ )
																												_a     					=    tokenizer_r(lowerCAmelCase_							,      return_offsets_mapping=lowerCAmelCase_							,      add_special_tokens=lowerCAmelCase_ )
																												self.assertEqual(encoding.offset_mapping[0]							,      (0, len(lowerCAmelCase_ )) )
																												self.assertEqual(
																												    encoding.offset_mapping[1]							,      (len(lowerCAmelCase_ ) + 1, len(lowerCAmelCase_ ) + 1 + len(lowerCAmelCase_ ))							,      )

																												_a     					=    self.rust_tokenizer_class.from_pretrained(
																												    lowerCAmelCase_							,      use_fast=lowerCAmelCase_							,      add_prefix_space=lowerCAmelCase_							,      trim_offsets=lowerCAmelCase_ )
																												_a     					=    tokenizer_r(lowerCAmelCase_							,      return_offsets_mapping=lowerCAmelCase_							,      add_special_tokens=lowerCAmelCase_ )
																												self.assertEqual(encoding.offset_mapping[0]							,      (0, len(lowerCAmelCase_ )) )
																												self.assertEqual(
																												    encoding.offset_mapping[1]							,      (len(lowerCAmelCase_ ), len(lowerCAmelCase_ ) + 1 + len(lowerCAmelCase_ ))							,      )

																												_a     					=    self.rust_tokenizer_class.from_pretrained(
																												    lowerCAmelCase_							,      use_fast=lowerCAmelCase_							,      add_prefix_space=lowerCAmelCase_							,      trim_offsets=lowerCAmelCase_ )
																												_a     					=    tokenizer_r(lowerCAmelCase_							,      return_offsets_mapping=lowerCAmelCase_							,      add_special_tokens=lowerCAmelCase_ )
																												self.assertEqual(encoding.offset_mapping[0]							,      (0, len(lowerCAmelCase_ )) )
																												self.assertEqual(
																												    encoding.offset_mapping[1]							,      (len(lowerCAmelCase_ ), len(lowerCAmelCase_ ) + 1 + len(lowerCAmelCase_ ))							,      )

																												_a     					=    F' {text}'

																												# tokenizer_r = self.rust_tokenizer_class.from_pretrained(
																												#     pretrained_name, use_fast=True, add_prefix_space=True, trim_offsets=True
																												# )
																												# encoding = tokenizer_r(text, return_offsets_mapping=True, add_special_tokens=False)
																												# self.assertEqual(encoding.offset_mapping[0], (1, 1 + len(text_of_1_token)))
																												# self.assertEqual(
																												#     encoding.offset_mapping[1],
																												#     (1 + len(text_of_1_token) + 1, 1 + len(text_of_1_token) + 1 + len(text_of_1_token)),
																												# )

																												_a     					=    self.rust_tokenizer_class.from_pretrained(
																												    lowerCAmelCase_							,      use_fast=lowerCAmelCase_							,      add_prefix_space=lowerCAmelCase_							,      trim_offsets=lowerCAmelCase_ )
																												_a     					=    tokenizer_r(lowerCAmelCase_							,      return_offsets_mapping=lowerCAmelCase_							,      add_special_tokens=lowerCAmelCase_ )
																												self.assertEqual(encoding.offset_mapping[0]							,      (1, 1 + len(lowerCAmelCase_ )) )
																												self.assertEqual(
																												    encoding.offset_mapping[1]							,      (1 + len(lowerCAmelCase_ ) + 1, 1 + len(lowerCAmelCase_ ) + 1 + len(lowerCAmelCase_ ))							,      )

																												_a     					=    self.rust_tokenizer_class.from_pretrained(
																												    lowerCAmelCase_							,      use_fast=lowerCAmelCase_							,      add_prefix_space=lowerCAmelCase_							,      trim_offsets=lowerCAmelCase_ )
																												_a     					=    tokenizer_r(lowerCAmelCase_							,      return_offsets_mapping=lowerCAmelCase_							,      add_special_tokens=lowerCAmelCase_ )
																												self.assertEqual(encoding.offset_mapping[0]							,      (0, 1 + len(lowerCAmelCase_ )) )
																												self.assertEqual(
																												    encoding.offset_mapping[1]							,      (1 + len(lowerCAmelCase_ ), 1 + len(lowerCAmelCase_ ) + 1 + len(lowerCAmelCase_ ))							,      )

																												_a     					=    self.rust_tokenizer_class.from_pretrained(
																												    lowerCAmelCase_							,      use_fast=lowerCAmelCase_							,      add_prefix_space=lowerCAmelCase_							,      trim_offsets=lowerCAmelCase_ )
																												_a     					=    tokenizer_r(lowerCAmelCase_							,      return_offsets_mapping=lowerCAmelCase_							,      add_special_tokens=lowerCAmelCase_ )
																												self.assertEqual(encoding.offset_mapping[0]							,      (0, 1 + len(lowerCAmelCase_ )) )
																												self.assertEqual(
																												    encoding.offset_mapping[1]							,      (1 + len(lowerCAmelCase_ ), 1 + len(lowerCAmelCase_ ) + 1 + len(lowerCAmelCase_ ))							,      )







'''simple docstring'''


import tempfile
import unittest

import numpy as np
from huggingface_hub import HfFolder, delete_repo
from requests.exceptions import HTTPError

from transformers import BertConfig, is_flax_available
from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax


if is_flax_available():
				import os

				from flax.core.frozen_dict import unfreeze
				from flax.traverse_util import flatten_dict

				from transformers import FlaxBertModel

				_snake_case				:				Optional[Any]       							=		'0.12'  # assumed parallelism: 8

@require_flax
@is_staging_test
class       A   (		unittest.TestCase   ):







							@classmethod
							def        __lowerCAmelCase      (  cls	:  Tuple )      ->							int:


														"""simple docstring"""


														_a     					=    TOKEN
														HfFolder.save_token(lowerCAmelCase_ )







							@classmethod
							def        __lowerCAmelCase      (  cls	:  Tuple )      ->							Optional[int]:


														"""simple docstring"""


														try:
																					delete_repo(token=cls._token							,      repo_id='''test-model-flax''' )
														except HTTPError:
																					pass

														try:
																					delete_repo(token=cls._token							,      repo_id='''valid_org/test-model-flax-org''' )
														except HTTPError:
																					pass







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


														"""simple docstring"""


														_a     					=    BertConfig(
														    vocab_size=99							,      hidden_size=32							,      num_hidden_layers=5							,      num_attention_heads=4							,      intermediate_size=37 )
														_a     					=    FlaxBertModel(lowerCAmelCase_ )
														model.push_to_hub('''test-model-flax'''							,      use_auth_token=self._token )

														_a     					=    FlaxBertModel.from_pretrained(F'{USER}/test-model-flax' )

														_a     					=    flatten_dict(unfreeze(model.params ) )
														_a     					=    flatten_dict(unfreeze(new_model.params ) )

														for key in base_params.keys():
																					_a     					=    (base_params[key] - new_params[key]).sum().item()
																					self.assertLessEqual(lowerCAmelCase_							,      1e-3							,      msg=F'{key} not identical' )

														# Reset repo
														delete_repo(token=self._token							,      repo_id='''test-model-flax''' )

														# Push to hub via save_pretrained
														with tempfile.TemporaryDirectory() as tmp_dir:
																					model.save_pretrained(lowerCAmelCase_							,      repo_id='''test-model-flax'''							,      push_to_hub=lowerCAmelCase_							,      use_auth_token=self._token )

														_a     					=    FlaxBertModel.from_pretrained(F'{USER}/test-model-flax' )

														_a     					=    flatten_dict(unfreeze(model.params ) )
														_a     					=    flatten_dict(unfreeze(new_model.params ) )

														for key in base_params.keys():
																					_a     					=    (base_params[key] - new_params[key]).sum().item()
																					self.assertLessEqual(lowerCAmelCase_							,      1e-3							,      msg=F'{key} not identical' )







							def        __lowerCAmelCase      (  self	:  int )      ->							Tuple:


														"""simple docstring"""


														_a     					=    BertConfig(
														    vocab_size=99							,      hidden_size=32							,      num_hidden_layers=5							,      num_attention_heads=4							,      intermediate_size=37 )
														_a     					=    FlaxBertModel(lowerCAmelCase_ )
														model.push_to_hub('''valid_org/test-model-flax-org'''							,      use_auth_token=self._token )

														_a     					=    FlaxBertModel.from_pretrained('''valid_org/test-model-flax-org''' )

														_a     					=    flatten_dict(unfreeze(model.params ) )
														_a     					=    flatten_dict(unfreeze(new_model.params ) )

														for key in base_params.keys():
																					_a     					=    (base_params[key] - new_params[key]).sum().item()
																					self.assertLessEqual(lowerCAmelCase_							,      1e-3							,      msg=F'{key} not identical' )

														# Reset repo
														delete_repo(token=self._token							,      repo_id='''valid_org/test-model-flax-org''' )

														# Push to hub via save_pretrained
														with tempfile.TemporaryDirectory() as tmp_dir:
																					model.save_pretrained(
																					    lowerCAmelCase_							,      repo_id='''valid_org/test-model-flax-org'''							,      push_to_hub=lowerCAmelCase_							,      use_auth_token=self._token )

														_a     					=    FlaxBertModel.from_pretrained('''valid_org/test-model-flax-org''' )

														_a     					=    flatten_dict(unfreeze(model.params ) )
														_a     					=    flatten_dict(unfreeze(new_model.params ) )

														for key in base_params.keys():
																					_a     					=    (base_params[key] - new_params[key]).sum().item()
																					self.assertLessEqual(lowerCAmelCase_							,      1e-3							,      msg=F'{key} not identical' )



def 		snake_case_   (UpperCamelCase	:  List[str]			,						UpperCamelCase	:  Optional[Any]				):





							'''simple docstring'''


							_a     					=    True
							_a     					=    flatten_dict(modela.params				)
							_a     					=    flatten_dict(modela.params				)
							for key in flat_params_a.keys():
														if np.sum(np.abs(flat_params_a[key] - flat_params_a[key]				)				) > 1e-4:
																					_a     					=    False

							return models_are_equal

@require_flax
class       A   (		unittest.TestCase   ):







							def        __lowerCAmelCase      (  self	:  Dict )      ->							int:


														"""simple docstring"""


														_a     					=    BertConfig.from_pretrained('''hf-internal-testing/tiny-bert-flax-only''' )
														_a     					=    FlaxBertModel(lowerCAmelCase_ )

														_a     					=    '''bert'''
														with tempfile.TemporaryDirectory() as tmp_dir:
																					model.save_pretrained(os.path.join(lowerCAmelCase_							,      lowerCAmelCase_ ) )

																					with self.assertRaises(lowerCAmelCase_ ):
																												_a     					=    FlaxBertModel.from_pretrained(lowerCAmelCase_ )

																					_a     					=    FlaxBertModel.from_pretrained(lowerCAmelCase_							,      subfolder=lowerCAmelCase_ )

														self.assertTrue(check_models_equal(lowerCAmelCase_							,      lowerCAmelCase_ ) )







							def        __lowerCAmelCase      (  self	:  Union[str, Any] )      ->							Optional[int]:


														"""simple docstring"""


														_a     					=    BertConfig.from_pretrained('''hf-internal-testing/tiny-bert-flax-only''' )
														_a     					=    FlaxBertModel(lowerCAmelCase_ )

														_a     					=    '''bert'''
														with tempfile.TemporaryDirectory() as tmp_dir:
																					model.save_pretrained(os.path.join(lowerCAmelCase_							,      lowerCAmelCase_ )							,      max_shard_size='''10KB''' )

																					with self.assertRaises(lowerCAmelCase_ ):
																												_a     					=    FlaxBertModel.from_pretrained(lowerCAmelCase_ )

																					_a     					=    FlaxBertModel.from_pretrained(lowerCAmelCase_							,      subfolder=lowerCAmelCase_ )

														self.assertTrue(check_models_equal(lowerCAmelCase_							,      lowerCAmelCase_ ) )







							def        __lowerCAmelCase      (  self	:  Optional[Any] )      ->							List[str]:


														"""simple docstring"""


														_a     					=    '''bert'''
														_a     					=    '''hf-internal-testing/tiny-random-bert-subfolder'''

														with self.assertRaises(lowerCAmelCase_ ):
																					_a     					=    FlaxBertModel.from_pretrained(lowerCAmelCase_ )

														_a     					=    FlaxBertModel.from_pretrained(lowerCAmelCase_							,      subfolder=lowerCAmelCase_ )

														self.assertIsNotNone(lowerCAmelCase_ )







							def        __lowerCAmelCase      (  self	:  Tuple )      ->							Tuple:


														"""simple docstring"""


														_a     					=    '''bert'''
														_a     					=    '''hf-internal-testing/tiny-random-bert-sharded-subfolder'''
														with self.assertRaises(lowerCAmelCase_ ):
																					_a     					=    FlaxBertModel.from_pretrained(lowerCAmelCase_ )

														_a     					=    FlaxBertModel.from_pretrained(lowerCAmelCase_							,      subfolder=lowerCAmelCase_ )

														self.assertIsNotNone(lowerCAmelCase_ )

