






'''simple docstring'''
import importlib.metadata
import warnings
from copy import deepcopy

from packaging import version

from ..utils import logging
from .import_utils import is_accelerate_available, is_bitsandbytes_available


if is_bitsandbytes_available():
  import bitsandbytes as bnb
  import torch
  import torch.nn as nn

  from ..pytorch_utils import ConvaD

if is_accelerate_available():
  from accelerate import init_empty_weights
  from accelerate.utils import find_tied_parameters

a_					=	logging.get_logger(__name__)





def 	_a(					UpperCamelCase__			:  Union[str, Any],		UpperCamelCase__			:  Optional[Any],		UpperCamelCase__			:  Union[str, Any],		UpperCamelCase__			:  Tuple=None,		UpperCamelCase__			:  List[Any]=None							):




      '''simple docstring'''






      if "." in tensor_name:
            SCREAMING_SNAKE_CASE__       :			Any													=tensor_name.split('''.'''							)
            for split in splits[:-1]:
                  SCREAMING_SNAKE_CASE__       :			Dict													=getattr(UpperCamelCase__,		UpperCamelCase__							)
                  if new_module is None:
                        raise ValueError(f"{module} has no attribute {split}."							)
                  SCREAMING_SNAKE_CASE__       :			List[str]													=new_module
            SCREAMING_SNAKE_CASE__       :			Optional[int]													=splits[-1]

      if tensor_name not in module._parameters and tensor_name not in module._buffers:
            raise ValueError(f"{module} does not have a parameter or a buffer named {tensor_name}."							)
      SCREAMING_SNAKE_CASE__       :			List[str]													=tensor_name in module._buffers
      SCREAMING_SNAKE_CASE__       :			int													=getattr(UpperCamelCase__,		UpperCamelCase__							)

      if old_value.device == torch.device('''meta'''							) and device not in ["meta", torch.device('''meta'''							)] and value is None:
            raise ValueError(f"{tensor_name} is on the meta device, we need a `value` to put in on {device}."							)

      SCREAMING_SNAKE_CASE__       :			Optional[Any]													=False
      SCREAMING_SNAKE_CASE__       :			Any													=False
      if is_buffer or not is_bitsandbytes_available():
            SCREAMING_SNAKE_CASE__       :			Dict													=False
            SCREAMING_SNAKE_CASE__       :			Any													=False
      else:
            SCREAMING_SNAKE_CASE__       :			Dict													=hasattr(bnb.nn,		'''Params4bit'''							) and isinstance(module._parameters[tensor_name],		bnb.nn.Paramsabit							)
            SCREAMING_SNAKE_CASE__       :			int													=isinstance(module._parameters[tensor_name],		bnb.nn.IntaParams							)

      if is_abit or is_abit:
            SCREAMING_SNAKE_CASE__       :			Optional[Any]													=module._parameters[tensor_name]
            if param.device.type != "cuda":
                  if value is None:
                        SCREAMING_SNAKE_CASE__       :			Optional[Any]													=old_value.to(UpperCamelCase__							)
                  elif isinstance(UpperCamelCase__,		torch.Tensor							):
                        SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=value.to('''cpu'''							)
                        if value.dtype == torch.inta:
                              SCREAMING_SNAKE_CASE__       :			str													=version.parse(importlib.metadata.version('''bitsandbytes'''							)							) > version.parse(
                                  '''0.37.2'''							)
                              if not is_abit_serializable:
                                    raise ValueError(
                                        '''Detected int8 weights but the version of bitsandbytes is not compatible with int8 serialization. '''
                                        '''Make sure to download the latest `bitsandbytes` version. `pip install --upgrade bitsandbytes`.'''							)
                  else:
                        SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=torch.tensor(UpperCamelCase__,		device='''cpu'''							)

                  # Support models using `Conv1D` in place of `nn.Linear` (e.g. gpt2) by transposing the weight matrix prior to quantization.
                  # Since weights are saved in the correct "orientation", we skip transposing when loading.
                  if issubclass(module.source_cls,		UpperCamelCase__							) and fpaa_statistics is None:
                        SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=new_value.T

                  SCREAMING_SNAKE_CASE__       :			List[str]													=old_value.__dict__
                  if is_abit:
                        SCREAMING_SNAKE_CASE__       :			List[Any]													=bnb.nn.IntaParams(UpperCamelCase__,		requires_grad=UpperCamelCase__,		**UpperCamelCase__							).to(UpperCamelCase__							)
                  elif is_abit:
                        SCREAMING_SNAKE_CASE__       :			Tuple													=bnb.nn.Paramsabit(UpperCamelCase__,		requires_grad=UpperCamelCase__,		**UpperCamelCase__							).to(UpperCamelCase__							)

                  SCREAMING_SNAKE_CASE__       :			List[Any]													=new_value
                  if fpaa_statistics is not None:
                        setattr(module.weight,		'''SCB''',		fpaa_statistics.to(UpperCamelCase__							)							)

      else:
            if value is None:
                  SCREAMING_SNAKE_CASE__       :			int													=old_value.to(UpperCamelCase__							)
            elif isinstance(UpperCamelCase__,		torch.Tensor							):
                  SCREAMING_SNAKE_CASE__       :			List[str]													=value.to(UpperCamelCase__							)
            else:
                  SCREAMING_SNAKE_CASE__       :			List[Any]													=torch.tensor(UpperCamelCase__,		device=UpperCamelCase__							)

            if is_buffer:
                  SCREAMING_SNAKE_CASE__       :			Optional[int]													=new_value
            else:
                  SCREAMING_SNAKE_CASE__       :			Optional[Any]													=nn.Parameter(UpperCamelCase__,		requires_grad=old_value.requires_grad							)
                  SCREAMING_SNAKE_CASE__       :			Any													=new_value





def 	_a(					UpperCamelCase__			:  Dict,		UpperCamelCase__			:  Dict=None,		UpperCamelCase__			:  Optional[int]=None,		UpperCamelCase__			:  Tuple=None,		UpperCamelCase__			:  Union[str, Any]=False							):




      '''simple docstring'''






      for name, module in model.named_children():
            if current_key_name is None:
                  SCREAMING_SNAKE_CASE__       :			int													=[]
            current_key_name.append(UpperCamelCase__							)

            if (isinstance(UpperCamelCase__,		nn.Linear							) or isinstance(UpperCamelCase__,		UpperCamelCase__							)) and name not in modules_to_not_convert:
                  # Check if the current key is not in the `modules_to_not_convert`
                  if not any(key in '''.'''.join(UpperCamelCase__							) for key in modules_to_not_convert							):
                        with init_empty_weights():
                              if isinstance(UpperCamelCase__,		UpperCamelCase__							):
                                    SCREAMING_SNAKE_CASE__						,		SCREAMING_SNAKE_CASE__       :			str													=module.weight.shape
                              else:
                                    SCREAMING_SNAKE_CASE__       :			int													=module.in_features
                                    SCREAMING_SNAKE_CASE__       :			int													=module.out_features

                              if quantization_config.quantization_method() == "llm_int8":
                                    SCREAMING_SNAKE_CASE__       :			Optional[Any]													=bnb.nn.LinearabitLt(
                                        UpperCamelCase__,		UpperCamelCase__,		module.bias is not None,		has_fpaa_weights=quantization_config.llm_inta_has_fpaa_weight,		threshold=quantization_config.llm_inta_threshold,		)
                                    SCREAMING_SNAKE_CASE__       :			Tuple													=True
                              else:
                                    if (
                                        quantization_config.llm_inta_skip_modules is not None
                                        and name in quantization_config.llm_inta_skip_modules
                                    ):
                                          pass
                                    else:
                                          SCREAMING_SNAKE_CASE__       :			Optional[int]													=bnb.nn.Linearabit(
                                              UpperCamelCase__,		UpperCamelCase__,		module.bias is not None,		quantization_config.bnb_abit_compute_dtype,		compress_statistics=quantization_config.bnb_abit_use_double_quant,		quant_type=quantization_config.bnb_abit_quant_type,		)
                                          SCREAMING_SNAKE_CASE__       :			List[Any]													=True
                    # Store the module class in case we need to transpose the weight later
                              SCREAMING_SNAKE_CASE__       :			Dict													=type(UpperCamelCase__							)
                              # Force requires grad to False to avoid unexpected errors
                              model._modules[name].requires_grad_(UpperCamelCase__							)
            if len(list(module.children()							)							) > 0:
                  SCREAMING_SNAKE_CASE__						,		SCREAMING_SNAKE_CASE__       :			List[Any]													=_replace_with_bnb_linear(
                      UpperCamelCase__,		UpperCamelCase__,		UpperCamelCase__,		UpperCamelCase__,		has_been_replaced=UpperCamelCase__,		)
            # Remove the last key for recursion
            current_key_name.pop(-1							)
      return model, has_been_replaced





def 	_a(					UpperCamelCase__			:  Any,		UpperCamelCase__			:  Optional[Any]=None,		UpperCamelCase__			:  Optional[Any]=None,		UpperCamelCase__			:  Dict=None							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__       :			List[Any]													=['''lm_head'''] if modules_to_not_convert is None else modules_to_not_convert
      SCREAMING_SNAKE_CASE__						,		SCREAMING_SNAKE_CASE__       :			Any													=_replace_with_bnb_linear(
          UpperCamelCase__,		UpperCamelCase__,		UpperCamelCase__,		UpperCamelCase__							)

      if not has_been_replaced:
            logger.warning(
                '''You are loading your model in 8bit or 4bit but no linear modules were found in your model.'''
                ''' Please double check your model architecture, or submit an issue on github if you think this is'''
                ''' a bug.'''							)

      return model





def 	_a(					*UpperCamelCase__			:  str,		**UpperCamelCase__			:  List[str]							):




      '''simple docstring'''






      warnings.warn(
          '''`replace_8bit_linear` will be deprecated in a future version, please use `replace_with_bnb_linear` instead''',		UpperCamelCase__,		)
      return replace_with_bnb_linear(*UpperCamelCase__,		**UpperCamelCase__							)





def 	_a(					*UpperCamelCase__			:  str,		**UpperCamelCase__			:  Optional[int]							):




      '''simple docstring'''






      warnings.warn(
          '''`set_module_8bit_tensor_to_device` will be deprecated in a future version, please use `set_module_quantized_tensor_to_device` instead''',		UpperCamelCase__,		)
      return set_module_quantized_tensor_to_device(*UpperCamelCase__,		**UpperCamelCase__							)







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




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__       :			Optional[int]													=deepcopy(UpperCamelCase__							)  # this has 0 cost since it is done inside `init_empty_weights` context manager`
      tied_model.tie_weights()

      SCREAMING_SNAKE_CASE__       :			Dict													=find_tied_parameters(UpperCamelCase__							)
      # For compatibility with Accelerate < 0.18
      if isinstance(UpperCamelCase__,		UpperCamelCase__							):
            SCREAMING_SNAKE_CASE__       :			Optional[Any]													=sum(list(tied_params.values()							),		[]							) + list(tied_params.keys()							)
      else:
            SCREAMING_SNAKE_CASE__       :			List[str]													=sum(UpperCamelCase__,		[]							)
      SCREAMING_SNAKE_CASE__       :			List[Any]													=len(UpperCamelCase__							) > 0

      # Check if it is a base model
      SCREAMING_SNAKE_CASE__       :			Any													=not hasattr(UpperCamelCase__,		model.base_model_prefix							)

      # Ignore this for base models (BertModel, GPT2Model, etc.)
      if (not has_tied_params) and is_base_model:
            return []

      # otherwise they have an attached head
      SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=list(model.named_children()							)
      SCREAMING_SNAKE_CASE__       :			int													=[list_modules[-1][0]]

      # add last module together with tied weights
      SCREAMING_SNAKE_CASE__       :			int													=set(UpperCamelCase__							) - set(UpperCamelCase__							)
      SCREAMING_SNAKE_CASE__       :			List[Any]													=list(set(UpperCamelCase__							)							) + list(UpperCamelCase__							)

      # remove ".weight" from the keys
      SCREAMING_SNAKE_CASE__       :			Optional[int]													=['''.weight''', '''.bias''']
      SCREAMING_SNAKE_CASE__       :			Optional[int]													=[]
      for name in list_untouched:
            for name_to_remove in names_to_remove:
                  if name_to_remove in name:
                        SCREAMING_SNAKE_CASE__       :			str													=name.replace(UpperCamelCase__,		''''''							)
            filtered_module_names.append(UpperCamelCase__							)

      return filtered_module_names







'''simple docstring'''
from __future__ import annotations

import unittest

from transformers import AutoTokenizer, PegasusConfig, 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, TFPegasusForConditionalGeneration, TFPegasusModel






@require_tf
class        __SCREAMING_SNAKE_CASE :
 snake_case_												=							PegasusConfig
 snake_case_												=							{}
 snake_case_												=							"""gelu"""




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

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




 def        __magic_name__		( self		:							Any )		->  str:
       SCREAMING_SNAKE_CASE__       :			List[str]													=ids_tensor([self.batch_size, self.seq_length - 1]   , self.vocab_size )
       SCREAMING_SNAKE_CASE__       :			Optional[int]													=tf.expand_dims(tf.constant([self.eos_token_id] * self.batch_size )   , 1 )
       SCREAMING_SNAKE_CASE__       :			Any													=tf.concat([input_ids, eos_tensor]   , axis=1 )

       SCREAMING_SNAKE_CASE__       :			Dict													=ids_tensor([self.batch_size, self.seq_length]   , self.vocab_size )

       SCREAMING_SNAKE_CASE__       :			Optional[int]													=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   , )
       SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=prepare_pegasus_inputs_dict(__lowercase   , __lowercase   , __lowercase )
       return config, inputs_dict




 def        __magic_name__		( self		:							Optional[int]   , __lowercase		:							List[str]   , __lowercase		:							Optional[int] )		->  Tuple:
       SCREAMING_SNAKE_CASE__       :			List[Any]													=TFPegasusModel(config=__lowercase ).get_decoder()
       SCREAMING_SNAKE_CASE__       :			List[str]													=inputs_dict['''input_ids''']

       SCREAMING_SNAKE_CASE__       :			Tuple													=input_ids[:1, :]
       SCREAMING_SNAKE_CASE__       :			Tuple													=inputs_dict['''attention_mask'''][:1, :]
       SCREAMING_SNAKE_CASE__       :			Tuple													=inputs_dict['''head_mask''']
       SCREAMING_SNAKE_CASE__       :			List[str]													=1

       # first forward pass
       SCREAMING_SNAKE_CASE__       :			Any													=model(__lowercase   , attention_mask=__lowercase   , head_mask=__lowercase   , use_cache=__lowercase )

       SCREAMING_SNAKE_CASE__						,		SCREAMING_SNAKE_CASE__       :			Tuple													=outputs.to_tuple()

       # create hypothetical next token and extent to next_input_ids
       SCREAMING_SNAKE_CASE__       :			str													=ids_tensor((self.batch_size, 3)   , config.vocab_size )
       SCREAMING_SNAKE_CASE__       :			List[Any]													=tf.cast(ids_tensor((self.batch_size, 3)   , 2 )   , tf.inta )

       # append to next input_ids and
       SCREAMING_SNAKE_CASE__       :			Tuple													=tf.concat([input_ids, next_tokens]   , axis=-1 )
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=tf.concat([attention_mask, next_attn_mask]   , axis=-1 )

       SCREAMING_SNAKE_CASE__       :			int													=model(__lowercase   , attention_mask=__lowercase )[0]
       SCREAMING_SNAKE_CASE__       :			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
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=int(ids_tensor((1,)   , output_from_past.shape[-1] ) )
       SCREAMING_SNAKE_CASE__       :			Any													=output_from_no_past[:, -3:, random_slice_idx]
       SCREAMING_SNAKE_CASE__       :			List[str]													=output_from_past[:, :, random_slice_idx]

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





def 	_a(					UpperCamelCase__			:  Any,		UpperCamelCase__			:  Union[str, Any],		UpperCamelCase__			:  Union[str, Any],		UpperCamelCase__			:  Optional[Any]=None,		UpperCamelCase__			:  Optional[Any]=None,		UpperCamelCase__			:  Union[str, Any]=None,		UpperCamelCase__			:  Any=None,		UpperCamelCase__			:  Optional[Any]=None,		):




      '''simple docstring'''






      if attention_mask is None:
            SCREAMING_SNAKE_CASE__       :			str													=tf.cast(tf.math.not_equal(UpperCamelCase__,		config.pad_token_id							),		tf.inta							)
      if decoder_attention_mask is None:
            SCREAMING_SNAKE_CASE__       :			Any													=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:
            SCREAMING_SNAKE_CASE__       :			int													=tf.ones((config.encoder_layers, config.encoder_attention_heads)							)
      if decoder_head_mask is None:
            SCREAMING_SNAKE_CASE__       :			List[Any]													=tf.ones((config.decoder_layers, config.decoder_attention_heads)							)
      if cross_attn_head_mask is None:
            SCREAMING_SNAKE_CASE__       :			List[str]													=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        __SCREAMING_SNAKE_CASE (     lowerCamelCase		,			lowerCamelCase		,			unittest.TestCase			):
 snake_case_												=							(TFPegasusForConditionalGeneration, TFPegasusModel) if is_tf_available() else ()
 snake_case_												=							(TFPegasusForConditionalGeneration,) if is_tf_available() else ()
 snake_case_												=							(
     {
         """conversational""": TFPegasusForConditionalGeneration,
         """feature-extraction""": TFPegasusModel,
         """summarization""": TFPegasusForConditionalGeneration,
         """text2text-generation""": TFPegasusForConditionalGeneration,
         """translation""": TFPegasusForConditionalGeneration,
     }
     if is_tf_available()
     else {}
 )
 snake_case_												=							True
 snake_case_												=							False
 snake_case_												=							False




 def        __magic_name__		( self		:							Union[str, Any] )		->  str:
       SCREAMING_SNAKE_CASE__       :			List[Any]													=TFPegasusModelTester(self )
       SCREAMING_SNAKE_CASE__       :			Dict													=ConfigTester(self   , config_class=__lowercase )




 def        __magic_name__		( self		:							int )		->  Any:
       self.config_tester.run_common_tests()




 def        __magic_name__		( self		:							Optional[Any] )		->  List[Any]:
       SCREAMING_SNAKE_CASE__       :			Tuple													=self.model_tester.prepare_config_and_inputs_for_common()
       self.model_tester.check_decoder_model_past_large_inputs(*__lowercase )






@require_sentencepiece
@require_tokenizers
@require_tf
class        __SCREAMING_SNAKE_CASE (     unittest.TestCase			):
 snake_case_												=							[
     """ PG&E stated it scheduled the blackouts in response to forecasts for high winds amid dry conditions. The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were scheduled to be affected by the shutoffs which were expected to last through at least midday tomorrow.""",
     """ The London trio are up for best UK act and best album, as well as getting two nominations in the best song category.\"We got told like this morning 'Oh I think you're nominated'\", said Dappy.\"And I was like 'Oh yeah, which one?' And now we've got nominated for four awards. I mean, wow!\"Bandmate Fazer added: \"We thought it's best of us to come down and mingle with everyone and say hello to the cameras. And now we find we've got four nominations.\"The band have two shots at the best song prize, getting the nod for their Tynchy Stryder collaboration Number One, and single Strong Again.Their album Uncle B will also go up against records by the likes of Beyonce and Kanye West.N-Dubz picked up the best newcomer Mobo in 2007, but female member Tulisa said they wouldn't be too disappointed if they didn't win this time around.\"At the end of the day we're grateful to be where we are in our careers.\"If it don't happen then it don't happen - live to fight another day and keep on making albums and hits for the fans.\"Dappy also revealed they could be performing live several times on the night.The group will be doing Number One and also a possible rendition of the War Child single, I Got Soul.The charity song is a  re-working of The Killers' All These Things That I've Done and is set to feature artists like Chipmunk, Ironik and Pixie Lott.This year's Mobos will be held outside of London for the first time, in Glasgow on 30 September.N-Dubz said they were looking forward to performing for their Scottish fans and boasted about their recent shows north of the border.\"We just done Edinburgh the other day,\" said Dappy.\"We smashed up an N-Dubz show over there. We done Aberdeen about three or four months ago - we smashed up that show over there! Everywhere we go we smash it up!\" """,
 ]
 snake_case_												=							[
     """California's largest electricity provider has cut power to hundreds of thousands of customers in an effort to"""
     """ reduce the risk of wildfires.""",
     """N-Dubz have revealed they\'re \"grateful\" to have been nominated for four Mobo Awards.""",
 ]  # differs slightly from pytorch, likely due to numerical differences in linear layers
 snake_case_												=							"""google/pegasus-xsum"""




 @cached_property
 def        __magic_name__		( self		:							Optional[int] )		->  Tuple:
       return AutoTokenizer.from_pretrained(self.model_name )




 @cached_property
 def        __magic_name__		( self		:							List[Any] )		->  Optional[Any]:
       SCREAMING_SNAKE_CASE__       :			Optional[int]													=TFAutoModelForSeqaSeqLM.from_pretrained(self.model_name )
       return model




 def        __magic_name__		( self		:							List[str]   , **__lowercase		:							Any )		->  Optional[int]:
       SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=self.translate_src_text(**__lowercase )
       assert self.expected_text == generated_words




 def        __magic_name__		( self		:							Optional[Any]   , **__lowercase		:							List[str] )		->  Optional[int]:
       SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=self.tokenizer(self.src_text   , **__lowercase   , padding=__lowercase   , return_tensors='''tf''' )
       SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=self.model.generate(
           model_inputs.input_ids   , attention_mask=model_inputs.attention_mask   , num_beams=2   , use_cache=__lowercase   , )
       SCREAMING_SNAKE_CASE__       :			Any													=self.tokenizer.batch_decode(generated_ids.numpy()   , skip_special_tokens=__lowercase )
       return generated_words




 @slow
 def        __magic_name__		( self		:							Optional[Any] )		->  Optional[int]:
       self._assert_generated_batch_equal_expected()