



'''simple docstring'''




from __future__ import annotations

import unittest

from transformers import RoFormerConfig, 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 import (
						    TFRoFormerForCausalLM,
						    TFRoFormerForMaskedLM,
						    TFRoFormerForMultipleChoice,
						    TFRoFormerForQuestionAnswering,
						    TFRoFormerForSequenceClassification,
						    TFRoFormerForTokenClassification,
						    TFRoFormerModel,
						)
						from transformers.models.roformer.modeling_tf_roformer import (
						    TFRoFormerSelfAttention,
						    TFRoFormerSinusoidalPositionalEmbedding,
						)






class 		_UpperCamelCase						:


			'''simple docstring'''

			def __init__(							self  :				Dict							,  lowerCAmelCase__  :				Dict							,  lowerCAmelCase__  :				Optional[Any]=1_3							,  lowerCAmelCase__  :				str=7							,  lowerCAmelCase__  :				int=True							,  lowerCAmelCase__  :				Any=True							,  lowerCAmelCase__  :				Union[str, Any]=True							,  lowerCAmelCase__  :				List[Any]=True							,  lowerCAmelCase__  :				Optional[int]=9_9							,  lowerCAmelCase__  :				Optional[Any]=3_2							,  lowerCAmelCase__  :				Any=2							,  lowerCAmelCase__  :				int=4							,  lowerCAmelCase__  :				Union[str, Any]=3_7							,  lowerCAmelCase__  :				List[Any]="gelu"							,  lowerCAmelCase__  :				Optional[int]=0.1							,  lowerCAmelCase__  :				Union[str, Any]=0.1							,  lowerCAmelCase__  :				Dict=5_1_2							,  lowerCAmelCase__  :				Union[str, Any]=1_6							,  lowerCAmelCase__  :				Union[str, Any]=2							,  lowerCAmelCase__  :				Optional[Any]=0.02							,  lowerCAmelCase__  :				Optional[Any]=3							,  lowerCAmelCase__  :				List[Any]=4							,  lowerCAmelCase__  :				Dict=None							,  ):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Any					 =	parent
					__SCREAMING_SNAKE_CASE :	List[str]					 =	1_3
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	7
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	True
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	True
					__SCREAMING_SNAKE_CASE :	List[str]					 =	True
					__SCREAMING_SNAKE_CASE :	int					 =	True
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	9_9
					__SCREAMING_SNAKE_CASE :	List[str]					 =	3_2
					__SCREAMING_SNAKE_CASE :	str					 =	2
					__SCREAMING_SNAKE_CASE :	Any					 =	4
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	3_7
					__SCREAMING_SNAKE_CASE :	int					 =	"""gelu"""
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	0.1
					__SCREAMING_SNAKE_CASE :	Any					 =	0.1
					__SCREAMING_SNAKE_CASE :	List[str]					 =	5_1_2
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	1_6
					__SCREAMING_SNAKE_CASE :	Any					 =	2
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	0.02
					__SCREAMING_SNAKE_CASE :	Any					 =	3
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	4
					__SCREAMING_SNAKE_CASE :	int					 =	None

			def UpperCamelCase__      (							self  :				List[str]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	ids_tensor([self.batch_size, self.seq_length]							,  self.vocab_size		)

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

					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	None
					if self.use_token_type_ids:
							__SCREAMING_SNAKE_CASE :	Tuple					 =	ids_tensor([self.batch_size, self.seq_length]							,  self.type_vocab_size		)

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

					__SCREAMING_SNAKE_CASE :	Tuple					 =	RoFormerConfig(
					    vocab_size=self.vocab_size							,  hidden_size=self.hidden_size							,  num_hidden_layers=self.num_hidden_layers							,  num_attention_heads=self.num_attention_heads							,  intermediate_size=self.intermediate_size							,  hidden_act=self.hidden_act							,  hidden_dropout_prob=self.hidden_dropout_prob							,  attention_probs_dropout_prob=self.attention_probs_dropout_prob							,  max_position_embeddings=self.max_position_embeddings							,  type_vocab_size=self.type_vocab_size							,  initializer_range=self.initializer_range							,  return_dict=lowerCAmelCase__							,  )

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

			def UpperCamelCase__      (							self  :				List[Any]							,  lowerCAmelCase__  :				str							,  lowerCAmelCase__  :				str							,  lowerCAmelCase__  :				Union[str, Any]							,  lowerCAmelCase__  :				str							,  lowerCAmelCase__  :				Optional[Any]							,  lowerCAmelCase__  :				Tuple							,  lowerCAmelCase__  :				Union[str, Any]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[Any]					 =	TFRoFormerModel(config=lowerCAmelCase__		)
					__SCREAMING_SNAKE_CASE :	List[str]					 =	{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}

					__SCREAMING_SNAKE_CASE :	int					 =	[input_ids, input_mask]
					__SCREAMING_SNAKE_CASE :	List[str]					 =	model(lowerCAmelCase__		)

					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	model(lowerCAmelCase__		)

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

			def UpperCamelCase__      (							self  :				List[str]							,  lowerCAmelCase__  :				Dict							,  lowerCAmelCase__  :				List[str]							,  lowerCAmelCase__  :				Any							,  lowerCAmelCase__  :				Union[str, Any]							,  lowerCAmelCase__  :				Dict							,  lowerCAmelCase__  :				Tuple							,  lowerCAmelCase__  :				Any		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	str					 =	True
					__SCREAMING_SNAKE_CASE :	Tuple					 =	TFRoFormerForCausalLM(config=lowerCAmelCase__		)
					__SCREAMING_SNAKE_CASE :	Any					 =	{
					    """input_ids""": input_ids,
					    """attention_mask""": input_mask,
					    """token_type_ids""": token_type_ids,
					}
					__SCREAMING_SNAKE_CASE :	Dict					 =	model(lowerCAmelCase__		)["""logits"""]
					self.parent.assertListEqual(
					    list(prediction_scores.numpy().shape		)							,  [self.batch_size, self.seq_length, self.vocab_size]		)

			def UpperCamelCase__      (							self  :				Tuple							,  lowerCAmelCase__  :				Optional[Any]							,  lowerCAmelCase__  :				Union[str, Any]							,  lowerCAmelCase__  :				List[str]							,  lowerCAmelCase__  :				List[Any]							,  lowerCAmelCase__  :				List[str]							,  lowerCAmelCase__  :				Optional[int]							,  lowerCAmelCase__  :				Dict		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	TFRoFormerForMaskedLM(config=lowerCAmelCase__		)
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	{
					    """input_ids""": input_ids,
					    """attention_mask""": input_mask,
					    """token_type_ids""": token_type_ids,
					}
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	model(lowerCAmelCase__		)
					self.parent.assertEqual(result.logits.shape							,  (self.batch_size, self.seq_length, self.vocab_size)		)

			def UpperCamelCase__      (							self  :				Union[str, Any]							,  lowerCAmelCase__  :				List[str]							,  lowerCAmelCase__  :				Union[str, Any]							,  lowerCAmelCase__  :				Optional[Any]							,  lowerCAmelCase__  :				Union[str, Any]							,  lowerCAmelCase__  :				Union[str, Any]							,  lowerCAmelCase__  :				List[Any]							,  lowerCAmelCase__  :				str		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[Any]					 =	self.num_labels
					__SCREAMING_SNAKE_CASE :	str					 =	TFRoFormerForSequenceClassification(config=lowerCAmelCase__		)
					__SCREAMING_SNAKE_CASE :	Dict					 =	{
					    """input_ids""": input_ids,
					    """attention_mask""": input_mask,
					    """token_type_ids""": token_type_ids,
					}

					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	model(lowerCAmelCase__		)
					self.parent.assertEqual(result.logits.shape							,  (self.batch_size, self.num_labels)		)

			def UpperCamelCase__      (							self  :				Optional[int]							,  lowerCAmelCase__  :				str							,  lowerCAmelCase__  :				Any							,  lowerCAmelCase__  :				List[str]							,  lowerCAmelCase__  :				Dict							,  lowerCAmelCase__  :				Optional[Any]							,  lowerCAmelCase__  :				List[str]							,  lowerCAmelCase__  :				List[Any]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[str]					 =	self.num_choices
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	TFRoFormerForMultipleChoice(config=lowerCAmelCase__		)
					__SCREAMING_SNAKE_CASE :	Dict					 =	tf.tile(tf.expand_dims(lowerCAmelCase__							,  1		)							,  (1, self.num_choices, 1)		)
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	tf.tile(tf.expand_dims(lowerCAmelCase__							,  1		)							,  (1, self.num_choices, 1)		)
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	tf.tile(tf.expand_dims(lowerCAmelCase__							,  1		)							,  (1, self.num_choices, 1)		)
					__SCREAMING_SNAKE_CASE :	int					 =	{
					    """input_ids""": multiple_choice_inputs_ids,
					    """attention_mask""": multiple_choice_input_mask,
					    """token_type_ids""": multiple_choice_token_type_ids,
					}
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	model(lowerCAmelCase__		)
					self.parent.assertEqual(result.logits.shape							,  (self.batch_size, self.num_choices)		)

			def UpperCamelCase__      (							self  :				Any							,  lowerCAmelCase__  :				Optional[Any]							,  lowerCAmelCase__  :				Dict							,  lowerCAmelCase__  :				Dict							,  lowerCAmelCase__  :				int							,  lowerCAmelCase__  :				Dict							,  lowerCAmelCase__  :				Dict							,  lowerCAmelCase__  :				str		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[str]					 =	self.num_labels
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	TFRoFormerForTokenClassification(config=lowerCAmelCase__		)
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	{
					    """input_ids""": input_ids,
					    """attention_mask""": input_mask,
					    """token_type_ids""": token_type_ids,
					}
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	model(lowerCAmelCase__		)
					self.parent.assertEqual(result.logits.shape							,  (self.batch_size, self.seq_length, self.num_labels)		)

			def UpperCamelCase__      (							self  :				Union[str, Any]							,  lowerCAmelCase__  :				Optional[int]							,  lowerCAmelCase__  :				Union[str, Any]							,  lowerCAmelCase__  :				Optional[Any]							,  lowerCAmelCase__  :				List[str]							,  lowerCAmelCase__  :				int							,  lowerCAmelCase__  :				List[Any]							,  lowerCAmelCase__  :				Any		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	TFRoFormerForQuestionAnswering(config=lowerCAmelCase__		)
					__SCREAMING_SNAKE_CASE :	Any					 =	{
					    """input_ids""": input_ids,
					    """attention_mask""": input_mask,
					    """token_type_ids""": token_type_ids,
					}

					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	model(lowerCAmelCase__		)
					self.parent.assertEqual(result.start_logits.shape							,  (self.batch_size, self.seq_length)		)
					self.parent.assertEqual(result.end_logits.shape							,  (self.batch_size, self.seq_length)		)



			def UpperCamelCase__      (							self  :				Optional[Any]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[Any]					 =	self.prepare_config_and_inputs()
					(
					    (
					    __SCREAMING_SNAKE_CASE
					) ,		(
					    __SCREAMING_SNAKE_CASE
					) ,		(
					    __SCREAMING_SNAKE_CASE
					) ,		(
					    __SCREAMING_SNAKE_CASE
					) ,		(
					    __SCREAMING_SNAKE_CASE
					) ,		(
					    __SCREAMING_SNAKE_CASE
					) ,		(
					    __SCREAMING_SNAKE_CASE
					) ,		
					) :	Any					 =	config_and_inputs
					__SCREAMING_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 		_UpperCamelCase						(							lowerCamelCase__					,      lowerCamelCase__					,      unittest.TestCase					):


			'''simple docstring'''

			_A   :	List[str]    					=	(
			    (
			        TFRoFormerModel,
			        TFRoFormerForCausalLM,
			        TFRoFormerForMaskedLM,
			        TFRoFormerForQuestionAnswering,
			        TFRoFormerForSequenceClassification,
			        TFRoFormerForTokenClassification,
			        TFRoFormerForMultipleChoice,
			    )
			    if is_tf_available()
			    else ()
			)
			_A   :	Optional[int]    					=	(
			    {
			        '''feature-extraction''': TFRoFormerModel,
			        '''fill-mask''': TFRoFormerForMaskedLM,
			        '''question-answering''': TFRoFormerForQuestionAnswering,
			        '''text-classification''': TFRoFormerForSequenceClassification,
			        '''text-generation''': TFRoFormerForCausalLM,
			        '''token-classification''': TFRoFormerForTokenClassification,
			        '''zero-shot''': TFRoFormerForSequenceClassification,
			    }
			    if is_tf_available()
			    else {}
			)

			_A   :	Optional[Any]    					=	False
			_A   :	Any    					=	False

			def UpperCamelCase__      (							self  :				Optional[int]							,  lowerCAmelCase__  :				List[str]							,  lowerCAmelCase__  :				int							,  lowerCAmelCase__  :				Any							,  lowerCAmelCase__  :				Union[str, Any]							,  lowerCAmelCase__  :				Any		):





					"""simple docstring"""






					if pipeline_test_casse_name == "TextGenerationPipelineTests":
							return True

					return False

			def UpperCamelCase__      (							self  :				Dict		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[Any]					 =	TFRoFormerModelTester(self		)
					__SCREAMING_SNAKE_CASE :	List[str]					 =	ConfigTester(self							,  config_class=lowerCAmelCase__							,  hidden_size=3_7		)

			def UpperCamelCase__      (							self  :				int		):





					"""simple docstring"""






					self.config_tester.run_common_tests()

			def UpperCamelCase__      (							self  :				Optional[Any]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[Any]					 =	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_model(*lowerCAmelCase__		)

			def UpperCamelCase__      (							self  :				Optional[Any]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	str					 =	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_masked_lm(*lowerCAmelCase__		)

			def UpperCamelCase__      (							self  :				Optional[int]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_lm_head(*lowerCAmelCase__		)

			def UpperCamelCase__      (							self  :				int		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Any					 =	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_multiple_choice(*lowerCAmelCase__		)

			def UpperCamelCase__      (							self  :				Optional[int]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_question_answering(*lowerCAmelCase__		)

			def UpperCamelCase__      (							self  :				Dict		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Any					 =	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_sequence_classification(*lowerCAmelCase__		)

			def UpperCamelCase__      (							self  :				Tuple		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Tuple					 =	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_token_classification(*lowerCAmelCase__		)



			@slow
			def UpperCamelCase__      (							self  :				str		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Dict					 =	TFRoFormerModel.from_pretrained("""junnyu/roformer_chinese_base"""		)
					self.assertIsNotNone(lowerCAmelCase__		)






@require_tf
class 		_UpperCamelCase						(							unittest.TestCase					):


			'''simple docstring'''

			@slow
			def UpperCamelCase__      (							self  :				Any		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Any					 =	TFRoFormerForMaskedLM.from_pretrained("""junnyu/roformer_chinese_base"""		)
					__SCREAMING_SNAKE_CASE :	int					 =	tf.constant([[0, 1, 2, 3, 4, 5]]		)
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	model(lowerCAmelCase__		)[0]

					# TODO Replace vocab size
					__SCREAMING_SNAKE_CASE :	Tuple					 =	5_0_0_0_0

					__SCREAMING_SNAKE_CASE :	List[Any]					 =	[1, 6, vocab_size]
					self.assertEqual(output.shape							,  lowerCAmelCase__		)

					print(output[:, :3, :3]		)

					# TODO Replace values below with what was printed above.
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	tf.constant(
					    [
					        [
					            [-0.12_05_33_41, -1.0_26_49_01, 0.29_22_19_46],
					            [-1.5_13_37_83, 0.19_74_33, 0.15_19_06_07],
					            [-5.0_13_54_03, -3.90_02_56, -0.84_03_87_64],
					        ]
					    ]		)
					tf.debugging.assert_near(output[:, :3, :3]							,  lowerCAmelCase__							,  atol=1E-4		)






@require_tf
class 		_UpperCamelCase						(							unittest.TestCase					):


			'''simple docstring'''

			_A   :	List[str]    					=	1E-4

			def UpperCamelCase__      (							self  :				List[Any]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[str]					 =	tf.constant([[4, 1_0]]		)
					__SCREAMING_SNAKE_CASE :	Any					 =	TFRoFormerSinusoidalPositionalEmbedding(num_positions=6							,  embedding_dim=6		)

					__SCREAMING_SNAKE_CASE :	Dict					 =	emba(input_ids.shape		)
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	tf.constant(
					    [[0.00_00, 0.00_00, 0.00_00, 1.00_00, 1.00_00, 1.00_00], [0.84_15, 0.04_64, 0.00_22, 0.54_03, 0.99_89, 1.00_00]]		)

					tf.debugging.assert_near(lowerCAmelCase__							,  lowerCAmelCase__							,  atol=self.tolerance		)



			def UpperCamelCase__      (							self  :				Any		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	str					 =	tf.constant(
					    [
					        [0.00_00, 0.00_00, 0.00_00, 0.00_00, 0.00_00],
					        [0.84_15, 0.82_19, 0.80_20, 0.78_19, 0.76_17],
					        [0.90_93, 0.93_64, 0.95_81, 0.97_49, 0.98_70],
					    ]		)
					__SCREAMING_SNAKE_CASE :	Dict					 =	TFRoFormerSinusoidalPositionalEmbedding(num_positions=5_1_2							,  embedding_dim=5_1_2		)
					emba([2, 1_6, 5_1_2]		)
					__SCREAMING_SNAKE_CASE :	List[str]					 =	emba.weight[:3, :5]

					tf.debugging.assert_near(lowerCAmelCase__							,  lowerCAmelCase__							,  atol=self.tolerance		)






@require_tf
class 		_UpperCamelCase						(							unittest.TestCase					):


			'''simple docstring'''

			_A   :	List[Any]    					=	1E-4

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





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	str					 =	tf.reshape(tf.range(2 * 1_2 * 1_6 * 6_4							,  dtype=tf.floataa		)							,  shape=(2, 1_2, 1_6, 6_4)		) / 1_0_0

					__SCREAMING_SNAKE_CASE :	Dict					 =	-tf.reshape(tf.range(2 * 1_2 * 1_6 * 6_4							,  dtype=tf.floataa		)							,  shape=(2, 1_2, 1_6, 6_4)		) / 1_0_0

					__SCREAMING_SNAKE_CASE :	int					 =	TFRoFormerSinusoidalPositionalEmbedding(num_positions=3_2							,  embedding_dim=6_4		)
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	embed_positions([2, 1_6, 7_6_8]		)[None, None, :, :]

					__SCREAMING_SNAKE_CASE ,		__SCREAMING_SNAKE_CASE :	List[str]					 =	TFRoFormerSelfAttention.apply_rotary_position_embeddings(
					    lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__		)

					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	tf.constant(
					    [
					        [0.00_00, 0.01_00, 0.02_00, 0.03_00, 0.04_00, 0.05_00, 0.06_00, 0.07_00],
					        [-0.20_12, 0.88_97, 0.02_63, 0.94_01, 0.20_74, 0.94_63, 0.34_81, 0.93_43],
					        [-1.70_57, 0.62_71, -1.21_45, 1.38_97, -0.63_03, 1.76_47, -0.11_73, 1.89_85],
					        [-2.17_31, -1.63_97, -2.73_58, 0.28_54, -2.18_40, 1.71_83, -1.30_18, 2.48_71],
					        [0.27_17, -3.61_73, -2.92_06, -2.19_88, -3.66_38, 0.38_58, -2.91_55, 2.29_80],
					        [3.98_59, -2.15_80, -0.79_84, -4.49_04, -4.11_81, -2.02_52, -4.47_82, 1.12_53],
					    ]		)
					__SCREAMING_SNAKE_CASE :	List[str]					 =	tf.constant(
					    [
					        [0.00_00, -0.01_00, -0.02_00, -0.03_00, -0.04_00, -0.05_00, -0.06_00, -0.07_00],
					        [0.20_12, -0.88_97, -0.02_63, -0.94_01, -0.20_74, -0.94_63, -0.34_81, -0.93_43],
					        [1.70_57, -0.62_71, 1.21_45, -1.38_97, 0.63_03, -1.76_47, 0.11_73, -1.89_85],
					        [2.17_31, 1.63_97, 2.73_58, -0.28_54, 2.18_40, -1.71_83, 1.30_18, -2.48_71],
					        [-0.27_17, 3.61_73, 2.92_06, 2.19_88, 3.66_38, -0.38_58, 2.91_55, -2.29_80],
					        [-3.98_59, 2.15_80, 0.79_84, 4.49_04, 4.11_81, 2.02_52, 4.47_82, -1.12_53],
					    ]		)

					tf.debugging.assert_near(query_layer[0, 0, :6, :8]							,  lowerCAmelCase__							,  atol=self.tolerance		)
					tf.debugging.assert_near(key_layer[0, 0, :6, :8]							,  lowerCAmelCase__							,  atol=self.tolerance		)




'''simple docstring'''




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


UpperCamelCase__ :			List[Any]												=				{
    '''configuration_time_series_transformer''': [
        '''TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''TimeSeriesTransformerConfig''',
    ],
}

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__ :			List[Any]												=				[
						    '''TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''TimeSeriesTransformerForPrediction''',
						    '''TimeSeriesTransformerModel''',
						    '''TimeSeriesTransformerPreTrainedModel''',
						]


if TYPE_CHECKING:
						from .configuration_time_series_transformer import (
						    TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
						    TimeSeriesTransformerConfig,
						)

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_time_series_transformer import (
												    TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
												    TimeSeriesTransformerForPrediction,
												    TimeSeriesTransformerModel,
												    TimeSeriesTransformerPreTrainedModel,
												)

else:
						import sys

						UpperCamelCase__ :			Dict												=				_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)