






import json
import os
from functools import lru_cache
from typing import Dict, List, Optional, Tuple, Union

import regex as re

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...tokenization_utils_base import BatchEncoding, EncodedInput
from ...utils import PaddingStrategy, logging


a_		:						Tuple             =    logging.get_logger(__name__)


a_		:						Optional[Any]             =    {'vocab_file': 'vocab.json', 'merges_file': 'merges.txt'}

# See all LED models at https://huggingface.co/models?filter=LED
a_		:						List[str]             =    {
    'vocab_file': {
        'allenai/led-base-16384': 'https://huggingface.co/allenai/led-base-16384/resolve/main/vocab.json',
    },
    'merges_file': {
        'allenai/led-base-16384': 'https://huggingface.co/allenai/led-base-16384/resolve/main/merges.txt',
    },
    'tokenizer_file': {
        'allenai/led-base-16384': 'https://huggingface.co/allenai/led-base-16384/resolve/main/tokenizer.json',
    },
}

a_		:						Dict             =    {
    'allenai/led-base-16384': 1_63_84,
}






@lru_cache()
# Copied from transformers.models.bart.tokenization_bart.bytes_to_unicode
def 				lowerCamelCase__				():
			SCREAMING_SNAKE_CASE						= (
			    list(range(ord('!')							,       ord('~') + 1)) + list(range(ord('¡')							,       ord('¬') + 1)) + list(range(ord('®')							,       ord('ÿ') + 1))
			)
			SCREAMING_SNAKE_CASE						= bs[:]
			SCREAMING_SNAKE_CASE						= 0
			for b in range(2**8):
						if b not in bs:
									bs.append(_UpperCAmelCase)
									cs.append(2**8 + n)
									n += 1
			SCREAMING_SNAKE_CASE						= [chr(_UpperCAmelCase) for n in cs]
			return dict(zip(_UpperCAmelCase							,       _UpperCAmelCase))






def 				lowerCamelCase__				(_UpperCAmelCase):
			SCREAMING_SNAKE_CASE						= set()
			SCREAMING_SNAKE_CASE						= word[0]
			for char in word[1:]:
						pairs.add((prev_char, char))
						SCREAMING_SNAKE_CASE						= char
			return pairs







class 		_snake_case  (  A__					):
			_lowercase		:    Dict			     =							VOCAB_FILES_NAMES
			_lowercase		:    Any			     =							PRETRAINED_VOCAB_FILES_MAP
			_lowercase		:    Optional[Any]			     =							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			_lowercase		:    Optional[Any]			     =							['''input_ids''', '''attention_mask''']






			def __init__(       self		,					a		,					a		,					a="replace"		,					a="<s>"		,					a="</s>"		,					a="</s>"		,					a="<s>"		,					a="<unk>"		,					a="<pad>"		,					a="<mask>"		,					a=False		,					**a		,					)      ->       Optional[int]:
						SCREAMING_SNAKE_CASE						= AddedToken(a		,					lstrip=a		,					rstrip=a) if isinstance(a		,					a) else bos_token
						SCREAMING_SNAKE_CASE						= AddedToken(a		,					lstrip=a		,					rstrip=a) if isinstance(a		,					a) else eos_token
						SCREAMING_SNAKE_CASE						= AddedToken(a		,					lstrip=a		,					rstrip=a) if isinstance(a		,					a) else sep_token
						SCREAMING_SNAKE_CASE						= AddedToken(a		,					lstrip=a		,					rstrip=a) if isinstance(a		,					a) else cls_token
						SCREAMING_SNAKE_CASE						= AddedToken(a		,					lstrip=a		,					rstrip=a) if isinstance(a		,					a) else unk_token
						SCREAMING_SNAKE_CASE						= AddedToken(a		,					lstrip=a		,					rstrip=a) if isinstance(a		,					a) else pad_token

						# Mask token behave like a normal word, i.e. include the space before it
						SCREAMING_SNAKE_CASE						= AddedToken(a		,					lstrip=a		,					rstrip=a) if isinstance(a		,					a) else mask_token

						super().__init__(
						    errors=a		,					bos_token=a		,					eos_token=a		,					unk_token=a		,					sep_token=a		,					cls_token=a		,					pad_token=a		,					mask_token=a		,					add_prefix_space=a		,					**a		,					)

						with open(a		,					encoding='utf-8') as vocab_handle:
									SCREAMING_SNAKE_CASE						= json.load(a)
						SCREAMING_SNAKE_CASE						= {v: k for k, v in self.encoder.items()}
						SCREAMING_SNAKE_CASE						= errors  # how to handle errors in decoding
						SCREAMING_SNAKE_CASE						= bytes_to_unicode()
						SCREAMING_SNAKE_CASE						= {v: k for k, v in self.byte_encoder.items()}
						with open(a		,					encoding='utf-8') as merges_handle:
									SCREAMING_SNAKE_CASE						= merges_handle.read().split('\n')[1:-1]
						SCREAMING_SNAKE_CASE						= [tuple(merge.split()) for merge in bpe_merges]
						SCREAMING_SNAKE_CASE						= dict(zip(a		,					range(len(a))))
						SCREAMING_SNAKE_CASE						= {}
						SCREAMING_SNAKE_CASE						= add_prefix_space

						# Should have added re.IGNORECASE so BPE merges can happen for capitalized versions of contractions
						SCREAMING_SNAKE_CASE						= re.compile(R'\'s|\'t|\'re|\'ve|\'m|\'ll|\'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+')






			@property
			# Copied from transformers.models.bart.tokenization_bart.BartTokenizer.vocab_size
			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Tuple:
						return len(self.encoder)






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Optional[int]:
						return dict(self.encoder		,					**self.added_tokens_encoder)






			def    SCREAMING_SNAKE_CASE__    (       self		,					a)      ->       Any:
						if token in self.cache:
									return self.cache[token]
						SCREAMING_SNAKE_CASE						= tuple(a)
						SCREAMING_SNAKE_CASE						= get_pairs(a)

						if not pairs:
									return token

						while True:
									SCREAMING_SNAKE_CASE						= min(a		,					key=lambda a: self.bpe_ranks.get(a		,					float('inf')))
									if bigram not in self.bpe_ranks:
												break
									SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE						= bigram
									SCREAMING_SNAKE_CASE						= []
									SCREAMING_SNAKE_CASE						= 0
									while i < len(a):
												try:
															SCREAMING_SNAKE_CASE						= word.index(a		,					a)
												except ValueError:
															new_word.extend(word[i:])
															break
												else:
															new_word.extend(word[i:j])
															SCREAMING_SNAKE_CASE						= j

												if word[i] == first and i < len(a) - 1 and word[i + 1] == second:
															new_word.append(first + second)
															i += 2
												else:
															new_word.append(word[i])
															i += 1
									SCREAMING_SNAKE_CASE						= tuple(a)
									SCREAMING_SNAKE_CASE						= new_word
									if len(a) == 1:
												break
									else:
												SCREAMING_SNAKE_CASE						= get_pairs(a)
						SCREAMING_SNAKE_CASE						= ' '.join(a)
						SCREAMING_SNAKE_CASE						= word
						return word






			def    SCREAMING_SNAKE_CASE__    (       self		,					a)      ->       Optional[int]:
						SCREAMING_SNAKE_CASE						= []
						for token in re.findall(self.pat		,					a):
									SCREAMING_SNAKE_CASE						= ''.join(
									    self.byte_encoder[b] for b in token.encode('utf-8'))  # Maps all our bytes to unicode strings, avoiding control tokens of the BPE (spaces in our case)
									bpe_tokens.extend(bpe_token for bpe_token in self.bpe(a).split(' '))
						return bpe_tokens






			def    SCREAMING_SNAKE_CASE__    (       self		,					a)      ->       str:
						return self.encoder.get(a		,					self.encoder.get(self.unk_token))






			def    SCREAMING_SNAKE_CASE__    (       self		,					a)      ->       str:
						return self.decoder.get(a)






			def    SCREAMING_SNAKE_CASE__    (       self		,					a)      ->       Tuple:
						SCREAMING_SNAKE_CASE						= ''.join(a)
						SCREAMING_SNAKE_CASE						= bytearray([self.byte_decoder[c] for c in text]).decode('utf-8'		,					errors=self.errors)
						return text






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a = None)      ->       Tuple[str]:
						if not os.path.isdir(a):
									logger.error(f'''Vocabulary path ({save_directory}) should be a directory''')
									return
						SCREAMING_SNAKE_CASE						= os.path.join(
						    a		,					(filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file'])
						SCREAMING_SNAKE_CASE						= os.path.join(
						    a		,					(filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['merges_file'])

						with open(a		,					'w'		,					encoding='utf-8') as f:
									f.write(json.dumps(self.encoder		,					indent=2		,					sort_keys=a		,					ensure_ascii=a) + '\n')

						SCREAMING_SNAKE_CASE						= 0
						with open(a		,					'w'		,					encoding='utf-8') as writer:
									writer.write('#version: 0.2\n')
									for bpe_tokens, token_index in sorted(self.bpe_ranks.items()		,					key=lambda a: kv[1]):
												if index != token_index:
															logger.warning(
															    f'''Saving vocabulary to {merge_file}: BPE merge indices are not consecutive.'''
															    ' Please check that the tokenizer is not corrupted!')
															SCREAMING_SNAKE_CASE						= token_index
												writer.write(' '.join(a) + '\n')
												index += 1

						return vocab_file, merge_file






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a = None)      ->       List[int]:
						if token_ids_a is None:
									return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
						SCREAMING_SNAKE_CASE						= [self.cls_token_id]
						SCREAMING_SNAKE_CASE						= [self.sep_token_id]
						return cls + token_ids_a + sep + sep + token_ids_a + sep






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a = None		,					a = False)      ->       List[int]:
						if already_has_special_tokens:
									return super().get_special_tokens_mask(
									    token_ids_a=a		,					token_ids_a=a		,					already_has_special_tokens=a)

						if token_ids_a is None:
									return [1] + ([0] * len(a)) + [1]
						return [1] + ([0] * len(a)) + [1, 1] + ([0] * len(a)) + [1]






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a = None)      ->       List[int]:
						SCREAMING_SNAKE_CASE						= [self.sep_token_id]
						SCREAMING_SNAKE_CASE						= [self.cls_token_id]

						if token_ids_a is None:
									return len(cls + token_ids_a + sep) * [0]
						return len(cls + token_ids_a + sep + sep + token_ids_a + sep) * [0]






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a=False		,					**a)      ->       Any:
						SCREAMING_SNAKE_CASE						= kwargs.pop('add_prefix_space'		,					self.add_prefix_space)
						if (is_split_into_words or add_prefix_space) and (len(a) > 0 and not text[0].isspace()):
									SCREAMING_SNAKE_CASE						= ' ' + text
						return (text, kwargs)







			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a = None		,					a = PaddingStrategy.DO_NOT_PAD		,					a = None		,					a = None		,					)      ->       dict:
						SCREAMING_SNAKE_CASE						= super()._pad(
						    encoded_inputs=a		,					max_length=a		,					padding_strategy=a		,					pad_to_multiple_of=a		,					return_attention_mask=a		,					)

						# Load from model defaults
						if return_attention_mask is None:
									SCREAMING_SNAKE_CASE						= 'attention_mask' in self.model_input_names

						if return_attention_mask and "global_attention_mask" in encoded_inputs:
									SCREAMING_SNAKE_CASE						= encoded_inputs[self.model_input_names[0]]
									# `global_attention_mask` need to have the same length as other (sequential) inputs.
									SCREAMING_SNAKE_CASE						= len(encoded_inputs['global_attention_mask']) != len(a)

									if needs_to_be_padded:
												SCREAMING_SNAKE_CASE						= len(a) - len(encoded_inputs['global_attention_mask'])

												if self.padding_side == "right":
															# Use `-1` since `0` in `global_attention_mask` means `local attention` instead of `not to attend`
															SCREAMING_SNAKE_CASE						= (
															    encoded_inputs['global_attention_mask'] + [-1] * difference
															)
												elif self.padding_side == "left":
															SCREAMING_SNAKE_CASE						= [-1] * difference + encoded_inputs[
															    'global_attention_mask'
															]
												else:
															raise ValueError('Invalid padding strategy:' + str(self.padding_side))

						return encoded_inputs












from __future__ import annotations

import unittest

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

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


if is_tf_available():
				import numpy
				import tensorflow as tf

				from transformers.models.esm.modeling_tf_esm import (
				    TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFEsmForMaskedLM,
				    TFEsmForSequenceClassification,
				    TFEsmForTokenClassification,
				    TFEsmModel,
				)

class 		_snake_case  :






			def __init__(       self		,					a		,					)      ->       Tuple:
						SCREAMING_SNAKE_CASE						= parent
						SCREAMING_SNAKE_CASE						= 13
						SCREAMING_SNAKE_CASE						= 7
						SCREAMING_SNAKE_CASE						= True
						SCREAMING_SNAKE_CASE						= True
						SCREAMING_SNAKE_CASE						= True
						SCREAMING_SNAKE_CASE						= 99
						SCREAMING_SNAKE_CASE						= 32
						SCREAMING_SNAKE_CASE						= 2
						SCREAMING_SNAKE_CASE						= 4
						SCREAMING_SNAKE_CASE						= 37
						SCREAMING_SNAKE_CASE						= 'gelu'
						SCREAMING_SNAKE_CASE						= 0.1
						SCREAMING_SNAKE_CASE						= 0.1
						SCREAMING_SNAKE_CASE						= 512
						SCREAMING_SNAKE_CASE						= 16
						SCREAMING_SNAKE_CASE						= 2
						SCREAMING_SNAKE_CASE						= 0.02
						SCREAMING_SNAKE_CASE						= 3
						SCREAMING_SNAKE_CASE						= 4
						SCREAMING_SNAKE_CASE						= None






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       int:
						SCREAMING_SNAKE_CASE						= ids_tensor([self.batch_size, self.seq_length]		,					self.vocab_size)

						SCREAMING_SNAKE_CASE						= None
						if self.use_input_mask:
									SCREAMING_SNAKE_CASE						= random_attention_mask([self.batch_size, self.seq_length])

						SCREAMING_SNAKE_CASE						= None
						SCREAMING_SNAKE_CASE						= None
						SCREAMING_SNAKE_CASE						= None
						if self.use_labels:
									SCREAMING_SNAKE_CASE						= ids_tensor([self.batch_size]		,					self.type_sequence_label_size)
									SCREAMING_SNAKE_CASE						= ids_tensor([self.batch_size, self.seq_length]		,					self.num_labels)
									SCREAMING_SNAKE_CASE						= ids_tensor([self.batch_size]		,					self.num_choices)

						SCREAMING_SNAKE_CASE						= EsmConfig(
						    vocab_size=self.vocab_size		,					hidden_size=self.hidden_size		,					num_hidden_layers=self.num_hidden_layers		,					pad_token_id=1		,					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		,					)

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






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Tuple:
						(
						    (
						    SCREAMING_SNAKE_CASE
						)				,						(
						    SCREAMING_SNAKE_CASE
						)				,						(
						    SCREAMING_SNAKE_CASE
						)				,						(
						    SCREAMING_SNAKE_CASE
						)				,						(
						    SCREAMING_SNAKE_CASE
						)				,						(
						    SCREAMING_SNAKE_CASE
						)				,						
						)						= self.prepare_config_and_inputs()

						SCREAMING_SNAKE_CASE						= True
						SCREAMING_SNAKE_CASE						= floats_tensor([self.batch_size, self.seq_length, self.hidden_size])
						SCREAMING_SNAKE_CASE						= ids_tensor([self.batch_size, self.seq_length]		,					vocab_size=2)

						return (
						    config,
						    input_ids,
						    input_mask,
						    sequence_labels,
						    token_labels,
						    choice_labels,
						    encoder_hidden_states,
						    encoder_attention_mask,
						)






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a		,					a		,					a		,					a		,					a)      ->       List[str]:
						SCREAMING_SNAKE_CASE						= TFEsmModel(config=a)
						SCREAMING_SNAKE_CASE						= {'input_ids': input_ids, 'attention_mask': input_mask}
						SCREAMING_SNAKE_CASE						= model(a)

						SCREAMING_SNAKE_CASE						= [input_ids, input_mask]
						SCREAMING_SNAKE_CASE						= model(a)

						SCREAMING_SNAKE_CASE						= model(a)

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






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a		,					a		,					a		,					a		,					a		,					a		,					a		,					)      ->       str:
						SCREAMING_SNAKE_CASE						= True

						SCREAMING_SNAKE_CASE						= TFEsmModel(config=a)
						SCREAMING_SNAKE_CASE						= {
						    'input_ids': input_ids,
						    'attention_mask': input_mask,
						    'encoder_hidden_states': encoder_hidden_states,
						    'encoder_attention_mask': encoder_attention_mask,
						}
						SCREAMING_SNAKE_CASE						= model(a)

						SCREAMING_SNAKE_CASE						= [input_ids, input_mask]
						SCREAMING_SNAKE_CASE						= model(a		,					encoder_hidden_states=a)

						# Also check the case where encoder outputs are not passed
						SCREAMING_SNAKE_CASE						= model(a		,					attention_mask=a)

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






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a		,					a		,					a		,					a		,					a)      ->       Optional[int]:
						SCREAMING_SNAKE_CASE						= TFEsmForMaskedLM(config=a)
						SCREAMING_SNAKE_CASE						= model([input_ids, input_mask])
						self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.seq_length, self.vocab_size))






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a		,					a		,					a		,					a		,					a)      ->       Dict:
						SCREAMING_SNAKE_CASE						= self.num_labels
						SCREAMING_SNAKE_CASE						= TFEsmForTokenClassification(config=a)
						SCREAMING_SNAKE_CASE						= {'input_ids': input_ids, 'attention_mask': input_mask}
						SCREAMING_SNAKE_CASE						= model(a)
						self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.seq_length, self.num_labels))







			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Tuple:
						SCREAMING_SNAKE_CASE						= self.prepare_config_and_inputs()
						(
						    (
						    SCREAMING_SNAKE_CASE
						)				,						(
						    SCREAMING_SNAKE_CASE
						)				,						(
						    SCREAMING_SNAKE_CASE
						)				,						(
						    SCREAMING_SNAKE_CASE
						)				,						(
						    SCREAMING_SNAKE_CASE
						)				,						(
						    SCREAMING_SNAKE_CASE
						)				,						
						)						= config_and_inputs
						SCREAMING_SNAKE_CASE						= {'input_ids': input_ids, 'attention_mask': input_mask}
						return config, inputs_dict



@require_tf
class 		_snake_case  (  A__   ,    A__   ,    unittest.TestCase					):
			_lowercase		:    str			     =							(
			    (
			        TFEsmModel,
			        TFEsmForMaskedLM,
			        TFEsmForSequenceClassification,
			        TFEsmForTokenClassification,
			    )
			    if is_tf_available()
			    else ()
			)
			_lowercase		:    int			     =							(
			    {
			        '''feature-extraction''': TFEsmModel,
			        '''fill-mask''': TFEsmForMaskedLM,
			        '''text-classification''': TFEsmForSequenceClassification,
			        '''token-classification''': TFEsmForTokenClassification,
			        '''zero-shot''': TFEsmForSequenceClassification,
			    }
			    if is_tf_available()
			    else {}
			)
			_lowercase		:    str			     =							False
			_lowercase		:    Tuple			     =							False






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Tuple:
						SCREAMING_SNAKE_CASE						= TFEsmModelTester(self)
						SCREAMING_SNAKE_CASE						= ConfigTester(self		,					config_class=a		,					hidden_size=37)






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       str:
						self.config_tester.run_common_tests()






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Optional[int]:
						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*a)






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Tuple:
						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs_for_decoder()
						self.model_tester.create_and_check_model_as_decoder(*a)






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Optional[Any]:
						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_masked_lm(*a)






			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Optional[int]:
						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_token_classification(*a)






			@slow
			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Optional[Any]:
						for model_name in TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									SCREAMING_SNAKE_CASE						= TFEsmModel.from_pretrained(a)
									self.assertIsNotNone(a)






			@unittest.skip('Protein models do not support embedding resizing.')
			def    SCREAMING_SNAKE_CASE__    (       self)      ->       List[Any]:
						pass






			@unittest.skip('Protein models do not support embedding resizing.')
			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Dict:
						pass







			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Any:
						SCREAMING_SNAKE_CASE				,						SCREAMING_SNAKE_CASE						= self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
									SCREAMING_SNAKE_CASE						= model_class(a)
									assert isinstance(model.get_input_embeddings()		,					tf.keras.layers.Layer)
									if model_class is TFEsmForMaskedLM:
												# Output embedding test differs from the main test because they're a matrix, not a layer
												SCREAMING_SNAKE_CASE						= model.get_bias()
												assert isinstance(a		,					a)
												for k, v in name.items():
															assert isinstance(a		,					tf.Variable)
									else:
												SCREAMING_SNAKE_CASE						= model.get_output_embeddings()
												assert x is None
												SCREAMING_SNAKE_CASE						= model.get_bias()
												assert name is None



@require_tf
class 		_snake_case  (  unittest.TestCase					):






			@slow
			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Optional[Any]:
						SCREAMING_SNAKE_CASE						= TFEsmForMaskedLM.from_pretrained('facebook/esm2_t6_8M_UR50D')

						SCREAMING_SNAKE_CASE						= tf.constant([[0, 1, 2, 3, 4, 5]])
						SCREAMING_SNAKE_CASE						= model(a)[0]
						SCREAMING_SNAKE_CASE						= [1, 6, 33]
						self.assertEqual(list(output.numpy().shape)		,					a)
						# compare the actual values for a slice.
						SCREAMING_SNAKE_CASE						= tf.constant(
						    [
						        [
						            [8.92_15_18, -10.58_98_14, -6.4_67_13_07],
						            [-6.3_96_71_56, -13.91_13_77, -1.1_21_19_15],
						            [-7.78_12_47, -13.95_15_57, -3.74_05_92],
						        ]
						    ])
						self.assertTrue(numpy.allclose(output[:, :3, :3].numpy()		,					expected_slice.numpy()		,					atol=1E-2))







			@slow
			def    SCREAMING_SNAKE_CASE__    (       self)      ->       str:
						SCREAMING_SNAKE_CASE						= TFEsmModel.from_pretrained('facebook/esm2_t6_8M_UR50D')

						SCREAMING_SNAKE_CASE						= tf.constant([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]])
						SCREAMING_SNAKE_CASE						= model(a)[0]
						# compare the actual values for a slice.
						SCREAMING_SNAKE_CASE						= tf.constant(
						    [
						        [
						            [0.14_44_30_92, 0.54_12_53_27, 0.3_24_77_39],
						            [0.30_34_04_84, 0.00_52_66_76, 0.31_07_77_22],
						            [0.32_27_80_43, -0.24_98_70_96, 0.3_41_46_28],
						        ]
						    ])
						self.assertTrue(numpy.allclose(output[:, :3, :3].numpy()		,					expected_slice.numpy()		,					atol=1E-4))




