




"""simple docstring"""


from ..models.auto import AutoModelForSeqaSeqLM, AutoTokenizer
from .base import PipelineTool


A_      			=       {
    '''Acehnese Arabic''': '''ace_Arab''',
    '''Acehnese Latin''': '''ace_Latn''',
    '''Mesopotamian Arabic''': '''acm_Arab''',
    '''Ta\'izzi-Adeni Arabic''': '''acq_Arab''',
    '''Tunisian Arabic''': '''aeb_Arab''',
    '''Afrikaans''': '''afr_Latn''',
    '''South Levantine Arabic''': '''ajp_Arab''',
    '''Akan''': '''aka_Latn''',
    '''Amharic''': '''amh_Ethi''',
    '''North Levantine Arabic''': '''apc_Arab''',
    '''Modern Standard Arabic''': '''arb_Arab''',
    '''Modern Standard Arabic Romanized''': '''arb_Latn''',
    '''Najdi Arabic''': '''ars_Arab''',
    '''Moroccan Arabic''': '''ary_Arab''',
    '''Egyptian Arabic''': '''arz_Arab''',
    '''Assamese''': '''asm_Beng''',
    '''Asturian''': '''ast_Latn''',
    '''Awadhi''': '''awa_Deva''',
    '''Central Aymara''': '''ayr_Latn''',
    '''South Azerbaijani''': '''azb_Arab''',
    '''North Azerbaijani''': '''azj_Latn''',
    '''Bashkir''': '''bak_Cyrl''',
    '''Bambara''': '''bam_Latn''',
    '''Balinese''': '''ban_Latn''',
    '''Belarusian''': '''bel_Cyrl''',
    '''Bemba''': '''bem_Latn''',
    '''Bengali''': '''ben_Beng''',
    '''Bhojpuri''': '''bho_Deva''',
    '''Banjar Arabic''': '''bjn_Arab''',
    '''Banjar Latin''': '''bjn_Latn''',
    '''Standard Tibetan''': '''bod_Tibt''',
    '''Bosnian''': '''bos_Latn''',
    '''Buginese''': '''bug_Latn''',
    '''Bulgarian''': '''bul_Cyrl''',
    '''Catalan''': '''cat_Latn''',
    '''Cebuano''': '''ceb_Latn''',
    '''Czech''': '''ces_Latn''',
    '''Chokwe''': '''cjk_Latn''',
    '''Central Kurdish''': '''ckb_Arab''',
    '''Crimean Tatar''': '''crh_Latn''',
    '''Welsh''': '''cym_Latn''',
    '''Danish''': '''dan_Latn''',
    '''German''': '''deu_Latn''',
    '''Southwestern Dinka''': '''dik_Latn''',
    '''Dyula''': '''dyu_Latn''',
    '''Dzongkha''': '''dzo_Tibt''',
    '''Greek''': '''ell_Grek''',
    '''English''': '''eng_Latn''',
    '''Esperanto''': '''epo_Latn''',
    '''Estonian''': '''est_Latn''',
    '''Basque''': '''eus_Latn''',
    '''Ewe''': '''ewe_Latn''',
    '''Faroese''': '''fao_Latn''',
    '''Fijian''': '''fij_Latn''',
    '''Finnish''': '''fin_Latn''',
    '''Fon''': '''fon_Latn''',
    '''French''': '''fra_Latn''',
    '''Friulian''': '''fur_Latn''',
    '''Nigerian Fulfulde''': '''fuv_Latn''',
    '''Scottish Gaelic''': '''gla_Latn''',
    '''Irish''': '''gle_Latn''',
    '''Galician''': '''glg_Latn''',
    '''Guarani''': '''grn_Latn''',
    '''Gujarati''': '''guj_Gujr''',
    '''Haitian Creole''': '''hat_Latn''',
    '''Hausa''': '''hau_Latn''',
    '''Hebrew''': '''heb_Hebr''',
    '''Hindi''': '''hin_Deva''',
    '''Chhattisgarhi''': '''hne_Deva''',
    '''Croatian''': '''hrv_Latn''',
    '''Hungarian''': '''hun_Latn''',
    '''Armenian''': '''hye_Armn''',
    '''Igbo''': '''ibo_Latn''',
    '''Ilocano''': '''ilo_Latn''',
    '''Indonesian''': '''ind_Latn''',
    '''Icelandic''': '''isl_Latn''',
    '''Italian''': '''ita_Latn''',
    '''Javanese''': '''jav_Latn''',
    '''Japanese''': '''jpn_Jpan''',
    '''Kabyle''': '''kab_Latn''',
    '''Jingpho''': '''kac_Latn''',
    '''Kamba''': '''kam_Latn''',
    '''Kannada''': '''kan_Knda''',
    '''Kashmiri Arabic''': '''kas_Arab''',
    '''Kashmiri Devanagari''': '''kas_Deva''',
    '''Georgian''': '''kat_Geor''',
    '''Central Kanuri Arabic''': '''knc_Arab''',
    '''Central Kanuri Latin''': '''knc_Latn''',
    '''Kazakh''': '''kaz_Cyrl''',
    '''Kabiyè''': '''kbp_Latn''',
    '''Kabuverdianu''': '''kea_Latn''',
    '''Khmer''': '''khm_Khmr''',
    '''Kikuyu''': '''kik_Latn''',
    '''Kinyarwanda''': '''kin_Latn''',
    '''Kyrgyz''': '''kir_Cyrl''',
    '''Kimbundu''': '''kmb_Latn''',
    '''Northern Kurdish''': '''kmr_Latn''',
    '''Kikongo''': '''kon_Latn''',
    '''Korean''': '''kor_Hang''',
    '''Lao''': '''lao_Laoo''',
    '''Ligurian''': '''lij_Latn''',
    '''Limburgish''': '''lim_Latn''',
    '''Lingala''': '''lin_Latn''',
    '''Lithuanian''': '''lit_Latn''',
    '''Lombard''': '''lmo_Latn''',
    '''Latgalian''': '''ltg_Latn''',
    '''Luxembourgish''': '''ltz_Latn''',
    '''Luba-Kasai''': '''lua_Latn''',
    '''Ganda''': '''lug_Latn''',
    '''Luo''': '''luo_Latn''',
    '''Mizo''': '''lus_Latn''',
    '''Standard Latvian''': '''lvs_Latn''',
    '''Magahi''': '''mag_Deva''',
    '''Maithili''': '''mai_Deva''',
    '''Malayalam''': '''mal_Mlym''',
    '''Marathi''': '''mar_Deva''',
    '''Minangkabau Arabic ''': '''min_Arab''',
    '''Minangkabau Latin''': '''min_Latn''',
    '''Macedonian''': '''mkd_Cyrl''',
    '''Plateau Malagasy''': '''plt_Latn''',
    '''Maltese''': '''mlt_Latn''',
    '''Meitei Bengali''': '''mni_Beng''',
    '''Halh Mongolian''': '''khk_Cyrl''',
    '''Mossi''': '''mos_Latn''',
    '''Maori''': '''mri_Latn''',
    '''Burmese''': '''mya_Mymr''',
    '''Dutch''': '''nld_Latn''',
    '''Norwegian Nynorsk''': '''nno_Latn''',
    '''Norwegian Bokmål''': '''nob_Latn''',
    '''Nepali''': '''npi_Deva''',
    '''Northern Sotho''': '''nso_Latn''',
    '''Nuer''': '''nus_Latn''',
    '''Nyanja''': '''nya_Latn''',
    '''Occitan''': '''oci_Latn''',
    '''West Central Oromo''': '''gaz_Latn''',
    '''Odia''': '''ory_Orya''',
    '''Pangasinan''': '''pag_Latn''',
    '''Eastern Panjabi''': '''pan_Guru''',
    '''Papiamento''': '''pap_Latn''',
    '''Western Persian''': '''pes_Arab''',
    '''Polish''': '''pol_Latn''',
    '''Portuguese''': '''por_Latn''',
    '''Dari''': '''prs_Arab''',
    '''Southern Pashto''': '''pbt_Arab''',
    '''Ayacucho Quechua''': '''quy_Latn''',
    '''Romanian''': '''ron_Latn''',
    '''Rundi''': '''run_Latn''',
    '''Russian''': '''rus_Cyrl''',
    '''Sango''': '''sag_Latn''',
    '''Sanskrit''': '''san_Deva''',
    '''Santali''': '''sat_Olck''',
    '''Sicilian''': '''scn_Latn''',
    '''Shan''': '''shn_Mymr''',
    '''Sinhala''': '''sin_Sinh''',
    '''Slovak''': '''slk_Latn''',
    '''Slovenian''': '''slv_Latn''',
    '''Samoan''': '''smo_Latn''',
    '''Shona''': '''sna_Latn''',
    '''Sindhi''': '''snd_Arab''',
    '''Somali''': '''som_Latn''',
    '''Southern Sotho''': '''sot_Latn''',
    '''Spanish''': '''spa_Latn''',
    '''Tosk Albanian''': '''als_Latn''',
    '''Sardinian''': '''srd_Latn''',
    '''Serbian''': '''srp_Cyrl''',
    '''Swati''': '''ssw_Latn''',
    '''Sundanese''': '''sun_Latn''',
    '''Swedish''': '''swe_Latn''',
    '''Swahili''': '''swh_Latn''',
    '''Silesian''': '''szl_Latn''',
    '''Tamil''': '''tam_Taml''',
    '''Tatar''': '''tat_Cyrl''',
    '''Telugu''': '''tel_Telu''',
    '''Tajik''': '''tgk_Cyrl''',
    '''Tagalog''': '''tgl_Latn''',
    '''Thai''': '''tha_Thai''',
    '''Tigrinya''': '''tir_Ethi''',
    '''Tamasheq Latin''': '''taq_Latn''',
    '''Tamasheq Tifinagh''': '''taq_Tfng''',
    '''Tok Pisin''': '''tpi_Latn''',
    '''Tswana''': '''tsn_Latn''',
    '''Tsonga''': '''tso_Latn''',
    '''Turkmen''': '''tuk_Latn''',
    '''Tumbuka''': '''tum_Latn''',
    '''Turkish''': '''tur_Latn''',
    '''Twi''': '''twi_Latn''',
    '''Central Atlas Tamazight''': '''tzm_Tfng''',
    '''Uyghur''': '''uig_Arab''',
    '''Ukrainian''': '''ukr_Cyrl''',
    '''Umbundu''': '''umb_Latn''',
    '''Urdu''': '''urd_Arab''',
    '''Northern Uzbek''': '''uzn_Latn''',
    '''Venetian''': '''vec_Latn''',
    '''Vietnamese''': '''vie_Latn''',
    '''Waray''': '''war_Latn''',
    '''Wolof''': '''wol_Latn''',
    '''Xhosa''': '''xho_Latn''',
    '''Eastern Yiddish''': '''ydd_Hebr''',
    '''Yoruba''': '''yor_Latn''',
    '''Yue Chinese''': '''yue_Hant''',
    '''Chinese Simplified''': '''zho_Hans''',
    '''Chinese Traditional''': '''zho_Hant''',
    '''Standard Malay''': '''zsm_Latn''',
    '''Zulu''': '''zul_Latn''',
}






class       lowercase(  __a				):







 '''simple docstring'''





 lowercase__				      =      "facebook/nllb-200-distilled-600M"
 lowercase__				      =      (
     "This is a tool that translates text from a language to another. It takes three inputs: `text`, which should "
     "be the text to translate, `src_lang`, which should be the language of the text to translate and `tgt_lang`, "
     "which should be the language for the desired ouput language. Both `src_lang` and `tgt_lang` are written in "
     "plain English, such as 'Romanian', or 'Albanian'. It returns the text translated in `tgt_lang`."
 )
 lowercase__				      =      "translator"
 lowercase__				      =      AutoTokenizer
 lowercase__				      =      AutoModelForSeqaSeqLM
 lowercase__				      =      LANGUAGE_CODES

 lowercase__				      =      ["text", "text", "text"]
 lowercase__				      =      ["text"]


 def 				UpperCamelCase_     (       self:	str,   a_:	int,   a_:	Any,   a_:	Dict	):




   '''simple docstring'''



   if src_lang not in self.lang_to_code:
     raise ValueError(f"{src_lang} is not a supported language."	)
   if tgt_lang not in self.lang_to_code:
     raise ValueError(f"{tgt_lang} is not a supported language."	)
   _snake_case							:	List[Any]			=						self.lang_to_code[src_lang]
   _snake_case							:	int			=						self.lang_to_code[tgt_lang]
   return self.pre_processor._build_translation_inputs(
       a_,   return_tensors="""pt""",   src_lang=a_,   tgt_lang=a_	)


 def 				UpperCamelCase_     (       self:	List[str],   a_:	Optional[Any]	):




   '''simple docstring'''



   return self.model.generate(**a_	)


 def 				UpperCamelCase_     (       self:	Union[str, Any],   a_:	Optional[Any]	):




   '''simple docstring'''



   return self.post_processor.decode(outputs[0].tolist(),   skip_special_tokens=a_	)






"""simple docstring"""


import random
import timeit
from functools import wraps
from typing import Callable, Optional

from ..configuration_utils import PretrainedConfig
from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING
from ..utils import is_pyanvml_available, is_tf_available, logging
from .benchmark_utils import (
    Benchmark,
    Memory,
    MemorySummary,
    measure_peak_memory_cpu,
    start_memory_tracing,
    stop_memory_tracing,
)


if is_tf_available():
     import tensorflow as tf
     from tensorflow.python.framework.errors_impl import ResourceExhaustedError

     from .benchmark_args_tf import TensorFlowBenchmarkArguments

if is_pyanvml_available():
     import pyanvml.pyanvml as nvml

A_      			=       logging.get_logger(__name__)


def       UpperCAmelCase__ (snake_case__							:      bool	,     snake_case__							:      bool					):
  """simple docstring"""

  def run_func(snake_case__							:      Tuple					):
    @wraps(snake_case__					)
    def run_in_eager_mode(*snake_case__							:      str	,     **snake_case__							:      Any					):
      return func(*snake_case__	,     **snake_case__					)

    @wraps(snake_case__					)
    @tf.function(experimental_compile=snake_case__					)
    def run_in_graph_mode(*snake_case__							:      Any	,     **snake_case__							:      Optional[int]					):
      return func(*snake_case__	,     **snake_case__					)

    if do_eager_mode is True:
      if use_xla is not False:
        raise ValueError(
            """Cannot run model in XLA, if `args.eager_mode` is set to `True`. Please set `args.eager_mode=False`."""					)
      return run_in_eager_mode
    else:
      return run_in_graph_mode

  return run_func


def       UpperCAmelCase__ (snake_case__							:      int	,     snake_case__							:      int	,     snake_case__							:      int					):
  """simple docstring"""

  _snake_case							:	List[str]			=						random.Random()
  _snake_case							:	Optional[int]			=						[rng.randint(0	,     vocab_size - 1					) for i in range(batch_size * sequence_length					)]
  return tf.constant(snake_case__	,     shape=(batch_size, sequence_length)	,     dtype=tf.intaa					)






class       lowercase(  __a				):







 '''simple docstring'''





 lowercase__				      =      42
 lowercase__				      =      42
 lowercase__				      =      "TensorFlow"


 @property
 def 				UpperCamelCase_     (       self:	List[str]	):




   '''simple docstring'''



   return tf.__version__


 def 				UpperCamelCase_     (       self:	List[str],   a_:	str,   a_:	int,   a_:	int	):




   '''simple docstring'''



   _snake_case							:	List[str]			=						self.args.strategy
   if strategy is None:
     raise ValueError("""A device strategy has to be initialized before using TensorFlow."""	)
   _snake_case							:	Optional[int]			=						self._prepare_inference_func(a_,   a_,   a_	)
   return self._measure_speed(_inference	)


 def 				UpperCamelCase_     (       self:	int,   a_:	str,   a_:	int,   a_:	int	):




   '''simple docstring'''



   _snake_case							:	Tuple			=						self.args.strategy
   if strategy is None:
     raise ValueError("""A device strategy has to be initialized before using TensorFlow."""	)
   _snake_case							:	Optional[Any]			=						self._prepare_train_func(a_,   a_,   a_	)
   return self._measure_speed(_train	)


 def 				UpperCamelCase_     (       self:	Dict,   a_:	str,   a_:	int,   a_:	int	):




   '''simple docstring'''



   if self.args.is_gpu:
     tf.config.experimental.set_memory_growth(self.args.gpu_list[self.args.device_idx],   a_	)
   _snake_case							:	str			=						self.args.strategy
   if strategy is None:
     raise ValueError("""A device strategy has to be initialized before using TensorFlow."""	)
   _snake_case							:	List[str]			=						self._prepare_inference_func(a_,   a_,   a_	)
   return self._measure_memory(_inference	)


 def 				UpperCamelCase_     (       self:	Tuple,   a_:	str,   a_:	int,   a_:	int	):




   '''simple docstring'''



   if self.args.is_gpu:
     tf.config.experimental.set_memory_growth(self.args.gpu_list[self.args.device_idx],   a_	)
   _snake_case							:	Dict			=						self.args.strategy
   if strategy is None:
     raise ValueError("""A device strategy has to be initialized before using TensorFlow."""	)

   _snake_case							:	Optional[int]			=						self._prepare_train_func(a_,   a_,   a_	)
   return self._measure_memory(_train	)


 def 				UpperCamelCase_     (       self:	Optional[Any],   a_:	str,   a_:	int,   a_:	int	):




   '''simple docstring'''



   _snake_case							:	List[Any]			=						self.config_dict[model_name]

   if self.args.fpaa:
     raise NotImplementedError("""Mixed precision is currently not supported."""	)

   _snake_case							:	List[Any]			=						(
       hasattr(a_,   """architectures"""	)
       and isinstance(config.architectures,   a_	)
       and len(config.architectures	) > 0
   )
   if not self.args.only_pretrain_model and has_model_class_in_config:
     try:
       _snake_case							:	str			=						"""TF""" + config.architectures[0]  # prepend 'TF' for tensorflow model
       _snake_case							:	List[Any]			=						__import__("""transformers""",   fromlist=[model_class]	)
       _snake_case							:	Dict			=						getattr(a_,   a_	)
       _snake_case							:	Any			=						model_cls(a_	)
     except ImportError:
       raise ImportError(
           f"{model_class} does not exist. If you just want to test the pretrained model, you might want to"
           """ set `--only_pretrain_model` or `args.only_pretrain_model=True`."""	)
   else:
     _snake_case							:	Any			=						TF_MODEL_MAPPING[config.__class__](a_	)

   # encoder-decoder has vocab size saved differently
   _snake_case							:	List[Any]			=						config.vocab_size if hasattr(a_,   """vocab_size"""	) else config.encoder.vocab_size
   _snake_case							:	List[str]			=						random_input_ids(a_,   a_,   a_	)

   @run_with_tf_optimizations(self.args.eager_mode,   self.args.use_xla	)
   def encoder_decoder_forward():
     return model(a_,   decoder_input_ids=a_,   training=a_	)

   @run_with_tf_optimizations(self.args.eager_mode,   self.args.use_xla	)
   def encoder_forward():
     return model(a_,   training=a_	)

   _snake_case							:	Optional[int]			=						encoder_decoder_forward if config.is_encoder_decoder else encoder_forward

   return _inference


 def 				UpperCamelCase_     (       self:	Optional[int],   a_:	str,   a_:	int,   a_:	int	):




   '''simple docstring'''



   _snake_case							:	str			=						self.config_dict[model_name]

   if self.args.eager_mode is not False:
     raise ValueError("""Training cannot be done in eager mode. Please make sure that `args.eager_mode = False`."""	)

   if self.args.fpaa:
     raise NotImplementedError("""Mixed precision is currently not supported."""	)

   _snake_case							:	Tuple			=						(
       hasattr(a_,   """architectures"""	)
       and isinstance(config.architectures,   a_	)
       and len(config.architectures	) > 0
   )
   if not self.args.only_pretrain_model and has_model_class_in_config:
     try:
       _snake_case							:	List[str]			=						"""TF""" + config.architectures[0]  # prepend 'TF' for tensorflow model
       _snake_case							:	str			=						__import__("""transformers""",   fromlist=[model_class]	)
       _snake_case							:	Tuple			=						getattr(a_,   a_	)
       _snake_case							:	Any			=						model_cls(a_	)
     except ImportError:
       raise ImportError(
           f"{model_class} does not exist. If you just want to test the pretrained model, you might want to"
           """ set `--only_pretrain_model` or `args.only_pretrain_model=True`."""	)
   else:
     _snake_case							:	Optional[Any]			=						TF_MODEL_WITH_LM_HEAD_MAPPING[config.__class__](a_	)

   # encoder-decoder has vocab size saved differently
   _snake_case							:	List[Any]			=						config.vocab_size if hasattr(a_,   """vocab_size"""	) else config.encoder.vocab_size
   _snake_case							:	int			=						random_input_ids(a_,   a_,   a_	)

   @run_with_tf_optimizations(self.args.eager_mode,   self.args.use_xla	)
   def encoder_decoder_train():
     _snake_case							:	Dict			=						model(a_,   decoder_input_ids=a_,   labels=a_,   training=a_	)[0]
     _snake_case							:	str			=						tf.gradients(a_,   model.trainable_variables	)
     return gradients

   @run_with_tf_optimizations(self.args.eager_mode,   self.args.use_xla	)
   def encoder_train():
     _snake_case							:	Optional[Any]			=						model(a_,   labels=a_,   training=a_	)[0]
     _snake_case							:	Optional[Any]			=						tf.gradients(a_,   model.trainable_variables	)
     return gradients

   _snake_case							:	int			=						encoder_decoder_train if config.is_encoder_decoder else encoder_train

   return _train


 def 				UpperCamelCase_     (       self:	Union[str, Any],   a_:	str	):




   '''simple docstring'''



   with self.args.strategy.scope():
     try:
       if self.args.is_tpu or self.args.use_xla:
         # run additional 10 times to stabilize compilation for tpu
         logger.info("""Do inference on TPU. Running model 5 times to stabilize compilation"""	)
         timeit.repeat(a_,   repeat=1,   number=5	)

       # as written in https://docs.python.org/2/library/timeit.html#timeit.Timer.repeat, min should be taken rather than the average
       _snake_case							:	Dict			=						timeit.repeat(
           a_,   repeat=self.args.repeat,   number=10,   )

       return min(a_	) / 10.0
     except ResourceExhaustedError as e:
       self.print_fn(f"Doesn't fit on GPU. {e}"	)


 def 				UpperCamelCase_     (       self:	Optional[Any],   a_:	Callable[[], None]	):




   '''simple docstring'''



   logger.info(
       """Note that TensorFlow allocates more memory than """
       """it might need to speed up computation. """
       """The memory reported here corresponds to the memory """
       """reported by `nvidia-smi`, which can vary depending """
       """on total available memory on the GPU that is used."""	)
   with self.args.strategy.scope():
     try:
       if self.args.trace_memory_line_by_line:
         if not self.args.eager_mode:
           raise ValueError(
               """`args.eager_mode` is set to `False`. Make sure to run model in eager mode to measure memory"""
               """ consumption line by line."""	)
         _snake_case							:	List[Any]			=						start_memory_tracing("""transformers"""	)

       if self.args.is_tpu:
         # tpu
         raise NotImplementedError(
             """Memory Benchmarking is currently not implemented for TPU. Please disable memory benchmarking"""
             """ with `args.memory=False`"""	)
       elif self.args.is_gpu:
         # gpu
         if not is_pyanvml_available():
           logger.warning(
               """py3nvml not installed, we won't log GPU memory usage. """
               """Install py3nvml (pip install py3nvml) to log information about GPU."""	)
           _snake_case							:	Optional[Any]			=						"""N/A"""
         else:
           logger.info(
               """Measuring total GPU usage on GPU device. Make sure to not have additional processes"""
               """ running on the same GPU."""	)
           # init nvml
           nvml.nvmlInit()
           func()
           _snake_case							:	List[str]			=						nvml.nvmlDeviceGetHandleByIndex(self.args.device_idx	)
           _snake_case							:	Tuple			=						nvml.nvmlDeviceGetMemoryInfo(a_	)
           _snake_case							:	List[str]			=						meminfo.used
           _snake_case							:	Any			=						Memory(a_	)
           # shutdown nvml
           nvml.nvmlShutdown()
       else:
         # cpu
         if self.args.trace_memory_line_by_line:
           logger.info(
               """When enabling line by line tracing, the max peak memory for CPU is inaccurate in"""
               """ TensorFlow."""	)
           _snake_case							:	List[Any]			=						None
         else:
           _snake_case							:	int			=						measure_peak_memory_cpu(a_	)
           _snake_case							:	List[str]			=						Memory(a_	) if isinstance(a_,   a_	) else memory_bytes
       if self.args.trace_memory_line_by_line:
         _snake_case							:	Tuple			=						stop_memory_tracing(a_	)
         if memory is None:
           _snake_case							:	int			=						summary.total
       else:
         _snake_case							:	int			=						None

       return memory, summary
     except ResourceExhaustedError as e:
       self.print_fn(f"Doesn't fit on GPU. {e}"	)
       return "N/A", None


