'''simple docstring'''




import warnings

import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from sklearn.metrics import pairwise_distances

warnings.filterwarnings("ignore")

_lowercase		:					Optional[Any]													=		"K-MEANS-CLUST/ "




def 				lowerCamelCase      ( UpperCAmelCase__			:   List[Any] , UpperCAmelCase__			:   Optional[Any] , UpperCAmelCase__			:   List[str]=None					)     -> str:
							if seed is not None:  # useful for obtaining consistent results
														np.random.seed(UpperCAmelCase__					)
							lowercase_   :     Any									=			data.shape[0]  # number of data points

							# Pick K indices from range [0, N).
							lowercase_   :     int									=			np.random.randint(0 , UpperCAmelCase__ , UpperCAmelCase__					)

							# Keep centroids as dense format, as many entries will be nonzero due to averaging.
							# As long as at least one document in a cluster contains a word,
							# it will carry a nonzero weight in the TF-IDF vector of the centroid.
							lowercase_   :     List[Any]									=			data[rand_indices, :]

							return centroids




def 				lowerCamelCase      ( UpperCAmelCase__			:   Any , UpperCAmelCase__			:   List[str]					)     -> Tuple:
							return pairwise_distances(UpperCAmelCase__ , UpperCAmelCase__ , metric="""euclidean"""					)




def 				lowerCamelCase      ( UpperCAmelCase__			:   Dict , UpperCAmelCase__			:   Union[str, Any]					)     -> Any:
							# Compute distances between each data point and the set of centroids:
							# Fill in the blank (RHS only)
							lowercase_   :     Dict									=			centroid_pairwise_dist(UpperCAmelCase__ , UpperCAmelCase__					)

							# Compute cluster assignments for each data point:
							# Fill in the blank (RHS only)
							lowercase_   :     Optional[int]									=			np.argmin(UpperCAmelCase__ , axis=1					)

							return cluster_assignment




def 				lowerCamelCase      ( UpperCAmelCase__			:   List[Any] , UpperCAmelCase__			:   Any , UpperCAmelCase__			:   List[str]					)     -> Union[str, Any]:
							lowercase_   :     str									=			[]
							for i in range(UpperCAmelCase__					):
														# Select all data points that belong to cluster i. Fill in the blank (RHS only)
														lowercase_   :     int									=			data[cluster_assignment == i]
														# Compute the mean of the data points. Fill in the blank (RHS only)
														lowercase_   :     str									=			member_data_points.mean(axis=0					)
														new_centroids.append(UpperCAmelCase__					)
							lowercase_   :     int									=			np.array(UpperCAmelCase__					)

							return new_centroids




def 				lowerCamelCase      ( UpperCAmelCase__			:   Dict , UpperCAmelCase__			:   Optional[Any] , UpperCAmelCase__			:   int , UpperCAmelCase__			:   Tuple					)     -> Union[str, Any]:
							lowercase_   :     List[str]									=			0.0
							for i in range(UpperCAmelCase__					):
														# Select all data points that belong to cluster i. Fill in the blank (RHS only)
														lowercase_   :     Optional[int]									=			data[cluster_assignment == i, :]

														if member_data_points.shape[0] > 0:  # check if i-th cluster is non-empty
																					# Compute distances from centroid to data points (RHS only)
																					lowercase_   :     int									=			pairwise_distances(
																					    UpperCAmelCase__ , [centroids[i]] , metric="""euclidean"""					)
																					lowercase_   :     Optional[int]									=			distances**2
																					heterogeneity += np.sum(UpperCAmelCase__					)

							return heterogeneity




def 				lowerCamelCase      ( UpperCAmelCase__			:   str , UpperCAmelCase__			:   str					)     -> int:
							plt.figure(figsize=(7, 4)					)
							plt.plot(UpperCAmelCase__ , linewidth=4					)
							plt.xlabel("""# Iterations"""					)
							plt.ylabel("""Heterogeneity"""					)
							plt.title(F'''Heterogeneity of clustering over time, K={k:d}'''					)
							plt.rcParams.update({"""font.size""": 16}					)
							plt.show()




def 				lowerCamelCase      ( UpperCAmelCase__			:   str , UpperCAmelCase__			:   Any , UpperCAmelCase__			:   Optional[Any] , UpperCAmelCase__			:   Tuple=500 , UpperCAmelCase__			:   int=None , UpperCAmelCase__			:   int=False					)     -> Union[str, Any]:
							lowercase_   :     Any									=			initial_centroids[:]
							lowercase_   :     int									=			None

							for itr in range(UpperCAmelCase__					):
														if verbose:
																					print(UpperCAmelCase__ , end=""""""					)

														# 1. Make cluster assignments using nearest centroids
														lowercase_   :     Optional[Any]									=			assign_clusters(UpperCAmelCase__ , UpperCAmelCase__					)

														# 2. Compute a new centroid for each of the k clusters, averaging all data
														#    points assigned to that cluster.
														lowercase_   :     Any									=			revise_centroids(UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__					)

														# Check for convergence: if none of the assignments changed, stop
														if (
														    prev_cluster_assignment is not None
														    and (prev_cluster_assignment == cluster_assignment).all()
														):
																					break

														# Print number of new assignments
														if prev_cluster_assignment is not None:
																					lowercase_   :     int									=			np.sum(prev_cluster_assignment != cluster_assignment					)
																					if verbose:
																												print(
																												    F'''    {num_changed:5d} elements changed their cluster assignment.'''					)

        # Record heterogeneity convergence metric
														if record_heterogeneity is not None:
																					# YOUR CODE HERE
																					lowercase_   :     Dict									=			compute_heterogeneity(UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__					)
																					record_heterogeneity.append(UpperCAmelCase__					)

														lowercase_   :     str									=			cluster_assignment[:]

							return centroids, cluster_assignment


# Mock test below
if False:  # change to true to run this test case.
						from sklearn import datasets as ds

						_lowercase		:					List[Any]													=		ds.load_iris()
						_lowercase		:					List[Any]													=		3
						_lowercase		:					Optional[int]													=		[]
						_lowercase		:					str													=		get_initial_centroids(dataset["data"], k, seed=0)
						_lowercase							,			_lowercase		:					List[str]													=		kmeans(
						    dataset["data"],
						    k,
						    initial_centroids,
						    maxiter=400,
						    record_heterogeneity=heterogeneity,
						    verbose=True,
						)
						plot_heterogeneity(heterogeneity, k)




def 				lowerCamelCase      ( UpperCAmelCase__			:   pd.DataFrame , UpperCAmelCase__			:   np.ndarray , UpperCAmelCase__			:   str=None					)     -> pd.DataFrame:
							# Fill missing values with given rules
							if fill_missing_report:
														lowercase_   :     List[Any]									=			df.fillna(value=UpperCAmelCase__					)
							lowercase_   :     Any									=			1
							lowercase_   :     List[str]									=			df.select_dtypes(np.number					).columns
							lowercase_   :     List[Any]									=			(
							    df.groupby(["""Cluster"""]					)[  # construct report dataframe
							        numeric_cols
							    ]  # group by cluster number
							    .agg(
							        [
							            ("""sum""", np.sum),
							            ("""mean_with_zeros""", lambda UpperCAmelCase__					: np.mean(np.nan_to_num(UpperCAmelCase__					)					)),
							            ("""mean_without_zeros""", lambda UpperCAmelCase__					: x.replace(0 , np.NaN					).mean()),
							            (
							                """mean_25-75""",
							                lambda UpperCAmelCase__					: np.mean(
							                    np.nan_to_num(
							                        sorted(UpperCAmelCase__					)[
							                            round(len(UpperCAmelCase__					) * 25 / 100					) : round(len(UpperCAmelCase__					) * 75 / 100					)
							                        ]					)					),
							            ),
							            ("""mean_with_na""", np.mean),
							            ("""min""", lambda UpperCAmelCase__					: x.min()),
							            ("""5%""", lambda UpperCAmelCase__					: x.quantile(0.05					)),
							            ("""25%""", lambda UpperCAmelCase__					: x.quantile(0.25					)),
							            ("""50%""", lambda UpperCAmelCase__					: x.quantile(0.50					)),
							            ("""75%""", lambda UpperCAmelCase__					: x.quantile(0.75					)),
							            ("""95%""", lambda UpperCAmelCase__					: x.quantile(0.95					)),
							            ("""max""", lambda UpperCAmelCase__					: x.max()),
							            ("""count""", lambda UpperCAmelCase__					: x.count()),
							            ("""stdev""", lambda UpperCAmelCase__					: x.std()),
							            ("""mode""", lambda UpperCAmelCase__					: x.mode()[0]),
							            ("""median""", lambda UpperCAmelCase__					: x.median()),
							            ("""# > 0""", lambda UpperCAmelCase__					: (x > 0).sum()),
							        ]					)
							    .T.reset_index()
							    .rename(index=UpperCAmelCase__ , columns={"""level_0""": """Features""", """level_1""": """Type"""}					)
							)  # rename columns
							# calculate the size of cluster(count of clientID's)
							lowercase_   :     Optional[Any]									=			report[
							    (report["""Features"""] == """dummy""") & (report["""Type"""] == """count""")
							].copy()  # avoid SettingWithCopyWarning
							lowercase_   :     Any									=			(
							    """ClusterSize"""  # rename created cluster df to match report column names
							)
							lowercase_   :     Any									=			"""# of Customers"""
							lowercase_   :     Any									=			pd.DataFrame(
							    clustersize.iloc[:, 2:].values
							    / clustersize.iloc[:, 2:].values.sum()					)
							lowercase_   :     Optional[int]									=			"""% of Customers"""  # rename created cluster df to match report column names
							lowercase_   :     List[Any]									=			"""ClusterProportion"""
							lowercase_   :     Tuple									=			clusterproportion.columns.tolist()
							lowercase_   :     List[Any]									=			cols[-2:] + cols[:-2]
							lowercase_   :     Optional[int]									=			clusterproportion[cols]  # rearrange columns to match report
							lowercase_   :     Tuple									=			report.columns
							lowercase_   :     Tuple									=			pd.DataFrame(
							    abs(
							        report[report["""Type"""] == """count"""].iloc[:, 2:].values
							        - clustersize.iloc[:, 2:].values					)					)  # generating df with count of nan values
							lowercase_   :     Dict									=			0
							lowercase_   :     Optional[int]									=			"""# of nan"""
							lowercase_   :     Union[str, Any]									=			report[
							    report["""Type"""] == """count"""
							].Features.tolist()  # filling values in order to match report
							lowercase_   :     List[Any]									=			a.columns.tolist()
							lowercase_   :     Any									=			cols[-2:] + cols[:-2]
							lowercase_   :     Union[str, Any]									=			a[cols]  # rearrange columns to match report
							lowercase_   :     int									=			report.columns  # rename columns to match report
							lowercase_   :     Union[str, Any]									=			report.drop(
							    report[report.Type == """count"""].index					)  # drop count values except cluster size
							lowercase_   :     Any									=			pd.concat(
							    [report, a, clustersize, clusterproportion] , axis=0					)  # concat report with clustert size and nan values
							lowercase_   :     int									=			report["""Features"""].isin(UpperCAmelCase__					)
							lowercase_   :     Optional[int]									=			report.columns.tolist()
							lowercase_   :     List[Any]									=			cols[0:2] + cols[-1:] + cols[2:-1]
							lowercase_   :     Optional[int]									=			report[cols]
							lowercase_   :     str									=			{
							    """ClusterSize""": 9,
							    """ClusterProportion""": 8,
							    """mean_with_zeros""": 7,
							    """mean_with_na""": 6,
							    """max""": 5,
							    """50%""": 4,
							    """min""": 3,
							    """25%""": 2,
							    """75%""": 1,
							    """# of nan""": 0,
							    """# > 0""": -1,
							    """sum_with_na""": -2,
							}
							lowercase_   :     int									=			(
							    report.assign(
							        Sortera=lambda UpperCAmelCase__					: x.Type.map(UpperCAmelCase__					) , Sortera=lambda UpperCAmelCase__					: list(reversed(range(len(UpperCAmelCase__					)					)					)					) , )
							    .sort_values(["""Sorter1""", """Mark""", """Sorter2"""] , ascending=UpperCAmelCase__					)
							    .drop(["""Sorter1""", """Sorter2"""] , axis=1					)
							)
							lowercase_   :     Dict									=			""""""
							lowercase_   :     str									=			report.reset_index()
							lowercase_   :     Tuple									=			report.drop(columns=["""index"""]					)
							return report


if __name__ == "__main__":
						import doctest

						doctest.testmod()






'''simple docstring'''




from __future__ import annotations

import unittest
import warnings

from transformers import AutoTokenizer, MarianConfig, MarianTokenizer, TranslationPipeline, is_tf_available
from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow
from transformers.utils import cached_property

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


if is_tf_available():
						import tensorflow as tf

						from transformers import TFAutoModelForSeqaSeqLM, TFMarianModel, TFMarianMTModel





@require_tf
class        __magic_name__		:
			UpperCamelCase__							=			MarianConfig
			UpperCamelCase__							=			{}
			UpperCamelCase__							=			'''gelu'''







			def __init__(      self							:    Optional[Any]							,     lowercase_							:    Tuple							,     lowercase_							:    Optional[int]=13							,     lowercase_							:    Dict=7							,     lowercase_							:    str=True							,     lowercase_							:    str=False							,     lowercase_							:    Tuple=99							,     lowercase_							:    int=32							,     lowercase_							:    int=2							,     lowercase_							:    Optional[int]=4							,     lowercase_							:    Optional[int]=37							,     lowercase_							:    Any=0.1							,     lowercase_							:    List[Any]=0.1							,     lowercase_							:    Union[str, Any]=20							,     lowercase_							:    List[str]=2							,     lowercase_							:    int=1							,     lowercase_							:    Union[str, Any]=0							,     ):
										lowercase_   :     str									=			parent
										lowercase_   :     Any									=			batch_size
										lowercase_   :     List[Any]									=			seq_length
										lowercase_   :     str									=			is_training
										lowercase_   :     str									=			use_labels
										lowercase_   :     str									=			vocab_size
										lowercase_   :     Optional[Any]									=			hidden_size
										lowercase_   :     Optional[Any]									=			num_hidden_layers
										lowercase_   :     List[Any]									=			num_attention_heads
										lowercase_   :     List[Any]									=			intermediate_size

										lowercase_   :     List[str]									=			hidden_dropout_prob
										lowercase_   :     Union[str, Any]									=			attention_probs_dropout_prob
										lowercase_   :     str									=			max_position_embeddings
										lowercase_   :     Optional[int]									=			eos_token_id
										lowercase_   :     Dict									=			pad_token_id
										lowercase_   :     Any									=			bos_token_id







			def       SCREAMING_SNAKE_CASE_	(      self							:    Optional[int]       ):
										lowercase_   :     Optional[int]									=			ids_tensor([self.batch_size, self.seq_length - 1]							,     self.vocab_size       )
										lowercase_   :     Tuple									=			tf.expand_dims(tf.constant([self.eos_token_id] * self.batch_size       )							,     1       )
										lowercase_   :     Dict									=			tf.concat([input_ids, eos_tensor]							,     axis=1       )

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

										lowercase_   :     List[Any]									=			self.config_cls(
										    vocab_size=self.vocab_size							,     d_model=self.hidden_size							,     encoder_layers=self.num_hidden_layers							,     decoder_layers=self.num_hidden_layers							,     encoder_attention_heads=self.num_attention_heads							,     decoder_attention_heads=self.num_attention_heads							,     encoder_ffn_dim=self.intermediate_size							,     decoder_ffn_dim=self.intermediate_size							,     dropout=self.hidden_dropout_prob							,     attention_dropout=self.attention_probs_dropout_prob							,     max_position_embeddings=self.max_position_embeddings							,     eos_token_ids=[2]							,     bos_token_id=self.bos_token_id							,     pad_token_id=self.pad_token_id							,     decoder_start_token_id=self.pad_token_id							,     **self.config_updates							,     )
										lowercase_   :     List[Any]									=			prepare_marian_inputs_dict(lowercase_							,     lowercase_							,     lowercase_       )
										return config, inputs_dict







			def       SCREAMING_SNAKE_CASE_	(      self							:    Optional[Any]							,     lowercase_							:    List[Any]							,     lowercase_							:    Optional[int]       ):
										lowercase_   :     Any									=			TFMarianModel(config=lowercase_       ).get_decoder()
										lowercase_   :     Optional[Any]									=			inputs_dict["""input_ids"""]

										lowercase_   :     Tuple									=			input_ids[:1, :]
										lowercase_   :     Optional[Any]									=			inputs_dict["""attention_mask"""][:1, :]
										lowercase_   :     List[str]									=			inputs_dict["""head_mask"""]
										lowercase_   :     Dict									=			1

										# first forward pass
										lowercase_   :     List[Any]									=			model(lowercase_							,     attention_mask=lowercase_							,     head_mask=lowercase_							,     use_cache=lowercase_       )

										lowercase_		,		lowercase_   :     Any									=			outputs.to_tuple()

										# create hypothetical next token and extent to next_input_ids
										lowercase_   :     Any									=			ids_tensor((self.batch_size, 3)							,     config.vocab_size       )
										lowercase_   :     Dict									=			tf.cast(ids_tensor((self.batch_size, 3)							,     2       )							,     tf.inta       )

										# append to next input_ids and
										lowercase_   :     Dict									=			tf.concat([input_ids, next_tokens]							,     axis=-1       )
										lowercase_   :     Dict									=			tf.concat([attention_mask, next_attn_mask]							,     axis=-1       )

										lowercase_   :     Optional[int]									=			model(lowercase_							,     attention_mask=lowercase_       )[0]
										lowercase_   :     Union[str, Any]									=			model(lowercase_							,     attention_mask=lowercase_							,     past_key_values=lowercase_       )[0]

										self.parent.assertEqual(next_tokens.shape[1]							,     output_from_past.shape[1]       )

										# select random slice
										lowercase_   :     Union[str, Any]									=			int(ids_tensor((1,)							,     output_from_past.shape[-1]       )       )
										lowercase_   :     List[str]									=			output_from_no_past[:, -3:, random_slice_idx]
										lowercase_   :     Any									=			output_from_past[:, :, random_slice_idx]

										# test that outputs are equal for slice
										tf.debugging.assert_near(lowercase_							,     lowercase_							,     rtol=1E-3       )




def 				lowerCamelCase      ( UpperCAmelCase__			:   List[str] , UpperCAmelCase__			:   Dict , UpperCAmelCase__			:   List[Any] , UpperCAmelCase__			:   Tuple=None , UpperCAmelCase__			:   Union[str, Any]=None , UpperCAmelCase__			:   str=None , UpperCAmelCase__			:   Any=None , UpperCAmelCase__			:   Any=None , )     -> List[Any]:
							if attention_mask is None:
														lowercase_   :     Tuple									=			tf.cast(tf.math.not_equal(UpperCAmelCase__ , config.pad_token_id					) , tf.inta					)
							if decoder_attention_mask is None:
														lowercase_   :     Optional[int]									=			tf.concat(
														    [
														        tf.ones(decoder_input_ids[:, :1].shape , dtype=tf.inta					),
														        tf.cast(tf.math.not_equal(decoder_input_ids[:, 1:] , config.pad_token_id					) , tf.inta					),
														    ] , axis=-1 , )
							if head_mask is None:
														lowercase_   :     Union[str, Any]									=			tf.ones((config.encoder_layers, config.encoder_attention_heads)					)
							if decoder_head_mask is None:
														lowercase_   :     Optional[int]									=			tf.ones((config.decoder_layers, config.decoder_attention_heads)					)
							if cross_attn_head_mask is None:
														lowercase_   :     Any									=			tf.ones((config.decoder_layers, config.decoder_attention_heads)					)
							return {
							    "input_ids": input_ids,
							    "decoder_input_ids": decoder_input_ids,
							    "attention_mask": attention_mask,
							    "decoder_attention_mask": decoder_attention_mask,
							    "head_mask": head_mask,
							    "decoder_head_mask": decoder_head_mask,
							    "cross_attn_head_mask": cross_attn_head_mask,
							}





@require_tf
class        __magic_name__		(       _UpperCAmelCase,	_UpperCAmelCase,	unittest.TestCase):
			UpperCamelCase__							=			(TFMarianMTModel, TFMarianModel) if is_tf_available() else ()
			UpperCamelCase__							=			(TFMarianMTModel,) if is_tf_available() else ()
			UpperCamelCase__							=			(
			    {
			        '''conversational''': TFMarianMTModel,
			        '''feature-extraction''': TFMarianModel,
			        '''summarization''': TFMarianMTModel,
			        '''text2text-generation''': TFMarianMTModel,
			        '''translation''': TFMarianMTModel,
			    }
			    if is_tf_available()
			    else {}
			)
			UpperCamelCase__							=			True
			UpperCamelCase__							=			False
			UpperCamelCase__							=			False







			def       SCREAMING_SNAKE_CASE_	(      self							:    Dict       ):
										lowercase_   :     Dict									=			TFMarianModelTester(self       )
										lowercase_   :     Tuple									=			ConfigTester(self							,     config_class=lowercase_       )







			def       SCREAMING_SNAKE_CASE_	(      self							:    Optional[Any]       ):
										self.config_tester.run_common_tests()







			def       SCREAMING_SNAKE_CASE_	(      self							:    Any       ):
										lowercase_   :     Dict									=			self.model_tester.prepare_config_and_inputs_for_common()
										self.model_tester.check_decoder_model_past_large_inputs(*lowercase_       )





@require_tf
class        __magic_name__		(       unittest.TestCase):
			UpperCamelCase__							=			1000  # show more chars for failing integration tests







			@classmethod
			def       SCREAMING_SNAKE_CASE_	(      cls							:    Optional[int]       ):
										lowercase_   :     Optional[Any]									=			f'''Helsinki-NLP/opus-mt-{cls.src}-{cls.tgt}'''
										return cls







			@cached_property
			def       SCREAMING_SNAKE_CASE_	(      self							:    Tuple       ):
										return AutoTokenizer.from_pretrained(self.model_name       )







			@property
			def       SCREAMING_SNAKE_CASE_	(      self							:    Tuple       ):
										return self.tokenizer.eos_token_id







			@cached_property
			def       SCREAMING_SNAKE_CASE_	(      self							:    Optional[int]       ):
										warnings.simplefilter("""error"""       )
										lowercase_   :     TFMarianMTModel									=			TFAutoModelForSeqaSeqLM.from_pretrained(self.model_name       )
										assert isinstance(lowercase_							,     lowercase_       )
										lowercase_   :     List[Any]									=			model.config
										self.assertListEqual(c.bad_words_ids							,     [[c.pad_token_id]]       )
										self.assertEqual(c.max_length							,     512       )
										self.assertEqual(c.decoder_start_token_id							,     c.pad_token_id       )
										return model







			def       SCREAMING_SNAKE_CASE_	(      self							:    Union[str, Any]							,     **lowercase_							:    str       ):
										lowercase_   :     List[Any]									=			self.translate_src_text(**lowercase_       )
										self.assertListEqual(self.expected_text							,     lowercase_       )







			def       SCREAMING_SNAKE_CASE_	(      self							:    Union[str, Any]							,     **lowercase_							:    Dict       ):
										lowercase_   :     Dict									=			self.tokenizer(self.src_text							,     **lowercase_							,     padding=lowercase_							,     return_tensors="""tf"""       )
										lowercase_   :     Tuple									=			self.model.generate(
										    model_inputs.input_ids							,     attention_mask=model_inputs.attention_mask							,     num_beams=2							,     max_length=128       )
										lowercase_   :     Any									=			self.tokenizer.batch_decode(generated_ids.numpy()							,     skip_special_tokens=lowercase_       )
										return generated_words





@require_sentencepiece
@require_tokenizers
@require_tf
class        __magic_name__		(       _UpperCAmelCase):
			UpperCamelCase__							=			'''mt'''
			UpperCamelCase__							=			'''en'''
			UpperCamelCase__							=			['''Billi messu b\'mod ġentili, Ġesù fejjaq raġel li kien milqut bil - marda kerha tal - ġdiem.''']
			UpperCamelCase__							=			['''Touching gently, Jesus healed a man who was affected by the sad disease of leprosy.''']







			@unittest.skip("""Skipping until #12647 is resolved."""       )
			@slow
			def       SCREAMING_SNAKE_CASE_	(      self							:    List[str]       ):
										self._assert_generated_batch_equal_expected()





@require_sentencepiece
@require_tokenizers
@require_tf
class        __magic_name__		(       _UpperCAmelCase):
			UpperCamelCase__							=			'''en'''
			UpperCamelCase__							=			'''zh'''
			UpperCamelCase__							=			['''My name is Wolfgang and I live in Berlin''']
			UpperCamelCase__							=			['''我叫沃尔夫冈 我住在柏林''']







			@unittest.skip("""Skipping until #12647 is resolved."""       )
			@slow
			def       SCREAMING_SNAKE_CASE_	(      self							:    str       ):
										self._assert_generated_batch_equal_expected()





@require_sentencepiece
@require_tokenizers
@require_tf
class        __magic_name__		(       _UpperCAmelCase):
			UpperCamelCase__							=			'''en'''
			UpperCamelCase__							=			'''ROMANCE'''
			UpperCamelCase__							=			[
			    '''>>fr<< Don\'t spend so much time watching TV.''',
			    '''>>pt<< Your message has been sent.''',
			    '''>>es<< He\'s two years older than me.''',
			]
			UpperCamelCase__							=			[
			    '''Ne passez pas autant de temps à regarder la télé.''',
			    '''A sua mensagem foi enviada.''',
			    '''Es dos años más viejo que yo.''',
			]







			@unittest.skip("""Skipping until #12647 is resolved."""       )
			@slow
			def       SCREAMING_SNAKE_CASE_	(      self							:    Optional[int]       ):
										self._assert_generated_batch_equal_expected()







			@unittest.skip("""Skipping until #12647 is resolved."""       )
			@slow
			def       SCREAMING_SNAKE_CASE_	(      self							:    Tuple       ):
										lowercase_   :     List[str]									=			TranslationPipeline(self.model							,     self.tokenizer							,     framework="""tf"""       )
										lowercase_   :     Optional[int]									=			pipeline(self.src_text       )
										self.assertEqual(self.expected_text							,     [x["""translation_text"""] for x in output]       )





