

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

import copy
import os
import tempfile
from importlib import import_module
from math import isnan

from transformers import is_tf_available
from transformers.models.auto import get_values
from transformers.testing_utils import _tf_gpu_memory_limit, require_tf, slow

from ..test_modeling_tf_common import ids_tensor


if is_tf_available():
					import numpy as np
					import tensorflow as tf

					from transformers import (
					    TF_MODEL_FOR_CAUSAL_LM_MAPPING,
					    TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
					    TF_MODEL_FOR_MASKED_LM_MAPPING,
					    TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
					    TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING,
					    TF_MODEL_FOR_PRETRAINING_MAPPING,
					    TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
					    TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
					    TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
					    TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
					    TFSharedEmbeddings,
					)

					if _tf_gpu_memory_limit is not None:
										_lowerCamelCase	 =			tf.config.list_physical_devices("""GPU""")
										for gpu in gpus:
															# Restrict TensorFlow to only allocate x GB of memory on the GPUs
															try:
																				tf.config.set_logical_device_configuration(
																				    gpu, [tf.config.LogicalDeviceConfiguration(memory_limit=_tf_gpu_memory_limit)]
																				)
																				_lowerCamelCase	 =			tf.config.list_logical_devices("""GPU""")
																				print("""Logical GPUs""", logical_gpus)
															except RuntimeError as e:
																				# Virtual devices must be set before GPUs have been initialized
																				print(e)
@require_tf
class  _snake_case						:
			__A   :     Optional[int]          =None
			__A   :     Optional[Any]          =()
			__A   :     Any          =()
			__A   :     List[Any]          =True
			__A   :     int          =True
			__A   :     List[Any]          =True
			__A   :     Tuple          =False






			def 						UpperCamelCase__				(   self       ,_snake_case       ,_snake_case       ,_snake_case=False			):
				UpperCAmelCase_			:	List[Any]      =   copy.deepcopy(_snake_case			)

				if model_class in get_values(_snake_case			):
					UpperCAmelCase_			:	Union[str, Any]      =   {
					    k: tf.tile(tf.expand_dims(_snake_case       ,1			)       ,(1, self.model_tester.num_choices) + (1,) * (v.ndim - 1)			)
					    if isinstance(_snake_case       ,tf.Tensor			) and v.ndim > 0
					    else v
					    for k, v in inputs_dict.items()
					}

				if return_labels:
					if model_class in get_values(_snake_case			):
						UpperCAmelCase_			:	Union[str, Any]      =   tf.ones(self.model_tester.batch_size       ,dtype=tf.intaa			)
					elif model_class in get_values(_snake_case			):
						UpperCAmelCase_			:	List[Any]      =   tf.zeros(self.model_tester.batch_size       ,dtype=tf.intaa			)
						UpperCAmelCase_			:	List[Any]      =   tf.zeros(self.model_tester.batch_size       ,dtype=tf.intaa			)
					elif model_class in [
					    *get_values(_snake_case			),
					    *get_values(_snake_case			),
					]:
						UpperCAmelCase_			:	Optional[Any]      =   tf.zeros(self.model_tester.batch_size       ,dtype=tf.intaa			)
					elif model_class in get_values(_snake_case			):
						UpperCAmelCase_			:	Optional[Any]      =   tf.zeros(self.model_tester.batch_size       ,dtype=tf.intaa			)
					elif model_class in [
					    *get_values(_snake_case			),
					    *get_values(_snake_case			),
					    *get_values(_snake_case			),
					    *get_values(_snake_case			),
					    *get_values(_snake_case			),
					]:
						UpperCAmelCase_			:	Dict      =   tf.zeros(
						    (self.model_tester.batch_size, self.model_tester.seq_length)       ,dtype=tf.intaa			)
				return inputs_dict






			@slow
			def 						UpperCamelCase__				(   self			):
				UpperCAmelCase_ , UpperCAmelCase_			:	List[str]      =   self.model_tester.prepare_config_and_inputs_for_common()
				for model_class in self.all_model_classes[:2]:
					UpperCAmelCase_			:	Optional[int]      =   self._prepare_for_class(_snake_case       ,_snake_case			)
					UpperCAmelCase_			:	str      =   model_class(_snake_case			)

					@tf.function
					def run_in_graph_mode():
						return model(_snake_case			)

					UpperCAmelCase_			:	int      =   run_in_graph_mode()
					self.assertIsNotNone(_snake_case			)






			@slow
			def 						UpperCamelCase__				(   self			):
				UpperCAmelCase_ , UpperCAmelCase_			:	Dict      =   self.model_tester.prepare_config_and_inputs_for_common()
				for model_class in self.all_model_classes[:2]:
					UpperCAmelCase_			:	str      =   self._prepare_for_class(_snake_case       ,_snake_case			)
					UpperCAmelCase_			:	List[Any]      =   model_class(_snake_case			)

					@tf.function(experimental_compile=_snake_case			)
					def run_in_graph_mode():
						return model(_snake_case			)

					UpperCAmelCase_			:	Union[str, Any]      =   run_in_graph_mode()
					self.assertIsNotNone(_snake_case			)






			@slow
			def 						UpperCamelCase__				(   self			):
				# This is a copy of the test_keras_fit method, but we use XLA compilation instead of eager
				UpperCAmelCase_ , UpperCAmelCase_			:	Optional[int]      =   self.model_tester.prepare_config_and_inputs_for_common()
				for model_class in self.all_model_classes[:2]:
					UpperCAmelCase_			:	List[str]      =   model_class(_snake_case			)
					if getattr(_snake_case       ,"hf_compute_loss"       ,_snake_case			):
						# Test that model correctly compute the loss with kwargs
						UpperCAmelCase_			:	Any      =   self._prepare_for_class(inputs_dict.copy()       ,_snake_case       ,return_labels=_snake_case			)
						# Is there a better way to remove these decoder inputs?
						UpperCAmelCase_			:	Optional[int]      =   {
						    key: val
						    for key, val in prepared_for_class.items()
						    if key not in ("head_mask", "decoder_head_mask", "cross_attn_head_mask", "decoder_input_ids")
						}

						UpperCAmelCase_			:	Any      =   {
						    "labels",
						    "label",
						    "label_ids",
						    "start_positions",
						    "start_position",
						    "end_positions",
						    "end_position",
						    "next_sentence_label",
						}
						UpperCAmelCase_			:	int      =   possible_label_cols.intersection(set(_snake_case			)			)
						self.assertGreater(len(_snake_case			)       ,0       ,msg="No matching label names found!"			)
						UpperCAmelCase_			:	Optional[Any]      =   {key: val for key, val in prepared_for_class.items() if key in label_names}
						UpperCAmelCase_			:	Optional[Any]      =   {key: val for key, val in prepared_for_class.items() if key not in label_names}
						self.assertGreater(len(_snake_case			)       ,0			)

						# Make sure it works with XLA!
						model.compile(optimizer=tf.keras.optimizers.SGD(0.0			)       ,jit_compile=_snake_case			)
						# Make sure the model fits without crashing regardless of where we pass the labels
						UpperCAmelCase_			:	Any      =   model.fit(
						    _snake_case       ,validation_data=_snake_case       ,steps_per_epoch=1       ,validation_steps=1       ,shuffle=_snake_case       ,verbose=0       ,)
						UpperCAmelCase_			:	Optional[int]      =   history.history["loss"][0]
						self.assertTrue(not isnan(_snake_case			)			)
						UpperCAmelCase_			:	Any      =   history.history["val_loss"][0]
						self.assertTrue(not isnan(_snake_case			)			)

						# Now test it with separate labels, to make sure that path works in XLA too.
						UpperCAmelCase_			:	Any      =   model_class(_snake_case			)
						model.compile(optimizer=tf.keras.optimizers.SGD(0.0			)       ,jit_compile=_snake_case			)
						UpperCAmelCase_			:	List[str]      =   model.fit(
						    _snake_case       ,_snake_case       ,validation_data=(inputs_minus_labels, labels)       ,steps_per_epoch=1       ,validation_steps=1       ,shuffle=_snake_case       ,verbose=0       ,)

						UpperCAmelCase_			:	str      =   history.history["loss"][0]
						self.assertTrue(not isnan(_snake_case			)			)
						UpperCAmelCase_			:	Union[str, Any]      =   history.history["val_loss"][0]
						self.assertTrue(not isnan(_snake_case			)			)






			@slow
			def 						UpperCamelCase__				(   self			):
				UpperCAmelCase_ , UpperCAmelCase_			:	Dict      =   self.model_tester.prepare_config_and_inputs_for_common()
				UpperCAmelCase_			:	Tuple      =   True
				UpperCAmelCase_			:	Optional[Any]      =   True

				if hasattr(_snake_case       ,"use_cache"			):
					UpperCAmelCase_			:	Union[str, Any]      =   True

				UpperCAmelCase_			:	Tuple      =   getattr(self.model_tester       ,"encoder_seq_length"       ,self.model_tester.seq_length			)
				UpperCAmelCase_			:	List[Any]      =   getattr(self.model_tester       ,"key_length"       ,_snake_case			)

				for model_class in self.all_model_classes[:2]:
					UpperCAmelCase_			:	List[str]      =   self._prepare_for_class(_snake_case       ,_snake_case			)
					UpperCAmelCase_			:	Optional[Any]      =   model_class(_snake_case			)
					model.build()
					UpperCAmelCase_			:	Any      =   len(model(_snake_case			)			)

					for key in list(class_inputs_dict.keys()			):
						# Remove keys not in the serving signature, as the SavedModel will not be compiled to deal with them
						if key not in model.input_signature:
							del class_inputs_dict[key]
						# Check it's a tensor, in case the inputs dict has some bools in it too
						elif isinstance(class_inputs_dict[key]       ,tf.Tensor			) and class_inputs_dict[key].dtype.is_integer:
							UpperCAmelCase_			:	List[Any]      =   tf.cast(class_inputs_dict[key]       ,tf.intaa			)

					if set(class_inputs_dict.keys()			) != set(model.input_signature.keys()			):
						continue  # Some models have inputs that the preparation functions don't create, we skip those

					with tempfile.TemporaryDirectory() as tmpdirname:
						model.save_pretrained(_snake_case       ,saved_model=_snake_case			)
						UpperCAmelCase_			:	List[Any]      =   os.path.join(_snake_case       ,"saved_model"       ,"1"			)
						UpperCAmelCase_			:	List[Any]      =   tf.keras.models.load_model(_snake_case			)
						UpperCAmelCase_			:	List[Any]      =   model(_snake_case			)

						if self.is_encoder_decoder:
							UpperCAmelCase_			:	int      =   outputs["encoder_hidden_states"]
							UpperCAmelCase_			:	int      =   outputs["encoder_attentions"]
						else:
							UpperCAmelCase_			:	Dict      =   outputs["hidden_states"]
							UpperCAmelCase_			:	List[str]      =   outputs["attentions"]

						self.assertEqual(len(_snake_case			)       ,_snake_case			)

						UpperCAmelCase_			:	int      =   getattr(
						    self.model_tester       ,"expected_num_hidden_layers"       ,self.model_tester.num_hidden_layers + 1			)

						self.assertEqual(len(_snake_case			)       ,_snake_case			)
						self.assertListEqual(
						    list(output_hidden_states[0].shape[-2:]			)       ,[self.model_tester.seq_length, self.model_tester.hidden_size]       ,)

						self.assertEqual(len(_snake_case			)       ,self.model_tester.num_hidden_layers			)
						self.assertListEqual(
						    list(output_attentions[0].shape[-3:]			)       ,[self.model_tester.num_attention_heads, encoder_seq_length, encoder_key_length]       ,)






			@slow
			def 						UpperCamelCase__				(   self			):
				tf.keras.mixed_precision.set_global_policy("mixed_float16"			)

				# try/finally block to ensure subsequent tests run in float32
				try:
					UpperCAmelCase_ , UpperCAmelCase_			:	Union[str, Any]      =   self.model_tester.prepare_config_and_inputs_for_common()
					for model_class in self.all_model_classes[:2]:
						UpperCAmelCase_			:	Dict      =   self._prepare_for_class(_snake_case       ,_snake_case			)
						UpperCAmelCase_			:	Optional[int]      =   model_class(_snake_case			)
						UpperCAmelCase_			:	List[Any]      =   model(_snake_case			)

						self.assertIsNotNone(_snake_case			)
				finally:
					tf.keras.mixed_precision.set_global_policy("float32"			)






			@slow
			def 						UpperCamelCase__				(   self			):
				UpperCAmelCase_ , UpperCAmelCase_			:	Any      =   self.model_tester.prepare_config_and_inputs_for_common()
				# head_mask and decoder_head_mask has different shapes than other input args
				if "head_mask" in inputs_dict:
					del inputs_dict["head_mask"]
				if "decoder_head_mask" in inputs_dict:
					del inputs_dict["decoder_head_mask"]
				if "cross_attn_head_mask" in inputs_dict:
					del inputs_dict["cross_attn_head_mask"]
				UpperCAmelCase_			:	Tuple      =   {
				    module_member
				    for model_class in self.all_model_classes
				    for module in (import_module(model_class.__module__			),)
				    for module_member_name in dir(_snake_case			)
				    if module_member_name.endswith("MainLayer"			)
				    for module_member in (getattr(_snake_case       ,_snake_case			),)
				    if isinstance(_snake_case       ,_snake_case			)
				    and tf.keras.layers.Layer in module_member.__bases__
				    and getattr(_snake_case       ,"_keras_serializable"       ,_snake_case			)
				}

				for main_layer_class in tf_main_layer_classes:
					# T5MainLayer needs an embed_tokens parameter when called without the inputs_embeds parameter
					if "T5" in main_layer_class.__name__:
						# Take the same values than in TFT5ModelTester for this shared layer
						UpperCAmelCase_			:	Optional[int]      =   TFSharedEmbeddings(self.model_tester.vocab_size       ,self.model_tester.hidden_size       ,name="shared"			)
						UpperCAmelCase_			:	str      =   False
						UpperCAmelCase_			:	Dict      =   main_layer_class(_snake_case       ,embed_tokens=_snake_case			)
					else:
						UpperCAmelCase_			:	List[Any]      =   main_layer_class(_snake_case			)

					UpperCAmelCase_			:	Optional[int]      =   {
					    name: tf.keras.Input(tensor.shape[1:]       ,dtype=tensor.dtype			) for name, tensor in inputs_dict.items()
					}

					if hasattr(self.model_tester       ,"num_labels"			):
						UpperCAmelCase_			:	Union[str, Any]      =   self.model_tester.num_labels
					else:
						UpperCAmelCase_			:	List[str]      =   2

					UpperCAmelCase_			:	Optional[int]      =   tf.data.Dataset.from_tensor_slices(
					    (inputs_dict, np.ones((self.model_tester.batch_size, self.model_tester.seq_length, num_labels, 1)			))			).batch(1			)

					UpperCAmelCase_			:	Dict      =   main_layer(_snake_case			)[0]
					UpperCAmelCase_			:	Any      =   tf.keras.layers.Dense(_snake_case       ,activation="softmax"       ,name="outputs"			)(_snake_case			)
					UpperCAmelCase_			:	str      =   tf.keras.models.Model(inputs=_snake_case       ,outputs=[outputs]			)

					model.compile(loss="binary_crossentropy"       ,optimizer="adam"       ,metrics=["binary_accuracy"]			)
					model.fit(_snake_case       ,epochs=1			)

					with tempfile.TemporaryDirectory() as tmpdirname:
						UpperCAmelCase_			:	Tuple      =   os.path.join(_snake_case       ,"keras_model.h5"			)
						model.save(_snake_case			)
						if "T5" in main_layer_class.__name__:
							UpperCAmelCase_			:	Tuple      =   tf.keras.models.load_model(
							    _snake_case       ,custom_objects={
							        main_layer_class.__name__: main_layer_class,
							        "TFSharedEmbeddings": TFSharedEmbeddings,
							    }       ,)
						else:
							UpperCAmelCase_			:	str      =   tf.keras.models.load_model(
							    _snake_case       ,custom_objects={main_layer_class.__name__: main_layer_class}			)
						assert isinstance(_snake_case       ,tf.keras.Model			)
						model(_snake_case			)






			@slow
			def 						UpperCamelCase__				(   self			):
				UpperCAmelCase_ , UpperCAmelCase_			:	List[Any]      =   self.model_tester.prepare_config_and_inputs_for_common()

				for model_class in self.all_model_classes[:2]:
					UpperCAmelCase_			:	List[str]      =   model_class(_snake_case			)

					UpperCAmelCase_			:	Union[str, Any]      =   copy.deepcopy(_snake_case			)

					if not self.is_encoder_decoder:
						UpperCAmelCase_			:	Union[str, Any]      =   inputs["input_ids"]
						del inputs["input_ids"]
					else:
						UpperCAmelCase_			:	int      =   inputs["input_ids"]
						UpperCAmelCase_			:	List[str]      =   inputs.get("decoder_input_ids"       ,_snake_case			)
						del inputs["input_ids"]
						inputs.pop("decoder_input_ids"       ,_snake_case			)

					if not self.is_encoder_decoder:
						UpperCAmelCase_			:	List[str]      =   model.get_input_embeddings()(_snake_case			)
					else:
						UpperCAmelCase_			:	int      =   model.get_input_embeddings()(_snake_case			)
						UpperCAmelCase_			:	Union[str, Any]      =   model.get_input_embeddings()(_snake_case			)

					UpperCAmelCase_			:	Any      =   self._prepare_for_class(_snake_case       ,_snake_case			)

					@tf.function
					def run_in_graph_mode():
						return model(_snake_case			)

					UpperCAmelCase_			:	int      =   run_in_graph_mode()
					self.assertIsNotNone(_snake_case			)






			def 						UpperCamelCase__				(   self       ,_snake_case       ,_snake_case			):
				# special tokens cannot be bad tokens
				UpperCAmelCase_			:	List[str]      =   []
				if model.config.bos_token_id is not None:
					special_tokens.append(model.config.bos_token_id			)
				if model.config.pad_token_id is not None:
					special_tokens.append(model.config.pad_token_id			)
				if model.config.eos_token_id is not None:
					special_tokens.append(model.config.eos_token_id			)

				# create random bad tokens that are not special tokens
				UpperCAmelCase_			:	List[str]      =   []
				while len(_snake_case			) < num_bad_tokens:
					UpperCAmelCase_			:	Optional[Any]      =   tf.squeeze(ids_tensor((1, 1)       ,self.model_tester.vocab_size			)       ,0			).numpy()[0]
					if token not in special_tokens:
						bad_tokens.append(_snake_case			)
				return bad_tokens






			def 						UpperCamelCase__				(   self       ,_snake_case			):
				for token_id in output_ids[0].numpy().tolist():
					self.assertGreaterEqual(_snake_case       ,0			)
					self.assertLess(_snake_case       ,self.model_tester.vocab_size			)






			def 						UpperCamelCase__				(   self       ,_snake_case       ,_snake_case			):
				# for all bad word tokens
				for bad_word_ids in bad_words_ids:
					# for all slices in batch
					for generated_ids_slice in generated_ids:
						# for all word idx
						for i in range(len(_snake_case			)       ,len(_snake_case			)			):
							# if tokens match
							if generated_ids_slice[i - len(_snake_case			) : i] == bad_word_ids:
								return True
				return False







'''simple docstring'''
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from typing import List


def       a__    (  _SCREAMING_SNAKE_CASE					:    List[str]     ,							_SCREAMING_SNAKE_CASE					:    str							)			-> Optional[Any]:


	"""simple docstring"""





	if name != "training_function" and name != "main":
		raise ValueError(F'''Incorrect function name passed: {name}, choose either \'main\' or \'training_function\''''							)
	UpperCAmelCase_ , UpperCAmelCase_			:	int      =   [], False
	for line in lines:
		if not found_start and F'''def {name}''' in line:
			UpperCAmelCase_			:	List[str]      =   True
			good_lines.append(_SCREAMING_SNAKE_CASE							)
			continue
		if found_start:
			if name == "training_function" and "def main" in line:
				return good_lines
			if name == "main" and "if __name__" in line:
				return good_lines
			good_lines.append(_SCREAMING_SNAKE_CASE							)


def       a__    (  _SCREAMING_SNAKE_CASE					:    List[str]							)			-> Optional[Any]:


	"""simple docstring"""





	return [line for line in lines if not line.lstrip().startswith("#"							) and line != "\n"]





def       a__    (  _SCREAMING_SNAKE_CASE					:    str     ,							_SCREAMING_SNAKE_CASE					:    str     ,							_SCREAMING_SNAKE_CASE					:    bool     ,							_SCREAMING_SNAKE_CASE					:    str = None							)			-> int:


	"""simple docstring"""





	with open(_SCREAMING_SNAKE_CASE     ,							"r"							) as f:
		UpperCAmelCase_			:	Union[str, Any]      =   f.readlines()
	with open(os.path.abspath(os.path.join("examples"     ,							"nlp_example.py"							)							)     ,							"r"							) as f:
		UpperCAmelCase_			:	Dict      =   f.readlines()
	with open(_SCREAMING_SNAKE_CASE     ,							"r"							) as f:
		UpperCAmelCase_			:	Any      =   f.readlines()
	if secondary_filename is not None:
		with open(_SCREAMING_SNAKE_CASE     ,							"r"							) as f:
			UpperCAmelCase_			:	Tuple      =   f.readlines()

    # This is our base, we remove all the code from here in our `full_filename` and `feature_filename` to find the new content
	if parser_only:
		UpperCAmelCase_			:	List[str]      =   clean_lines(get_function_contents_by_name(_SCREAMING_SNAKE_CASE     ,							"main"							)							)
		UpperCAmelCase_			:	Tuple      =   clean_lines(get_function_contents_by_name(_SCREAMING_SNAKE_CASE     ,							"main"							)							)
		UpperCAmelCase_			:	Tuple      =   clean_lines(get_function_contents_by_name(_SCREAMING_SNAKE_CASE     ,							"main"							)							)
		if secondary_filename is not None:
			UpperCAmelCase_			:	List[Any]      =   clean_lines(get_function_contents_by_name(_SCREAMING_SNAKE_CASE     ,							"main"							)							)
	else:
		UpperCAmelCase_			:	Union[str, Any]      =   clean_lines(get_function_contents_by_name(_SCREAMING_SNAKE_CASE     ,							"training_function"							)							)
		UpperCAmelCase_			:	str      =   clean_lines(get_function_contents_by_name(_SCREAMING_SNAKE_CASE     ,							"training_function"							)							)
		UpperCAmelCase_			:	List[Any]      =   clean_lines(get_function_contents_by_name(_SCREAMING_SNAKE_CASE     ,							"training_function"							)							)
		if secondary_filename is not None:
			UpperCAmelCase_			:	Tuple      =   clean_lines(
			    get_function_contents_by_name(_SCREAMING_SNAKE_CASE     ,							"training_function"							)							)

	UpperCAmelCase_			:	List[Any]      =   "train_dataloader, eval_dataloader = get_dataloaders(accelerator, batch_size)\n"

	# Specific code in our script that differs from the full version, aka what is new
	UpperCAmelCase_			:	Dict      =   []
	UpperCAmelCase_			:	Any      =   []  # We keep track of the idxs just in case it's a repeated statement
	UpperCAmelCase_			:	Optional[int]      =   iter(_SCREAMING_SNAKE_CASE							)
	for i in range(len(_SCREAMING_SNAKE_CASE							) - 1							):
		if i not in passed_idxs:
			UpperCAmelCase_			:	str      =   next(_SCREAMING_SNAKE_CASE							)
			if (line not in full_file_func) and (line.lstrip() != _dl_line):
				if "TESTING_MOCKED_DATALOADERS" not in line:
					new_feature_code.append(_SCREAMING_SNAKE_CASE							)
					passed_idxs.append(_SCREAMING_SNAKE_CASE							)
				else:
					# Skip over the `config['num_epochs'] = 2` statement
					UpperCAmelCase_			:	List[Any]      =   next(_SCREAMING_SNAKE_CASE							)

    # Extract out just the new parts from the full_file_training_func
	UpperCAmelCase_			:	Tuple      =   []
	UpperCAmelCase_			:	Optional[Any]      =   []  # We keep track of the idxs just in case it's a repeated statement
	for i, line in enumerate(_SCREAMING_SNAKE_CASE							):
		if i not in passed_idxs:
			if (line not in full_file_func) and (line.lstrip() != _dl_line):
				if "TESTING_MOCKED_DATALOADERS" not in line:
					new_full_example_parts.append(_SCREAMING_SNAKE_CASE							)
					passed_idxs.append(_SCREAMING_SNAKE_CASE							)

    # Finally, get the overall diff
	UpperCAmelCase_			:	Union[str, Any]      =   [line for line in new_feature_code if line not in new_full_example_parts]
	if secondary_filename is not None:
		UpperCAmelCase_			:	int      =   [line for line in full_file_contents if line not in secondary_file_func]
		UpperCAmelCase_			:	str      =   [line for line in diff_from_example if line not in diff_from_two]

	return diff_from_example




