


import copy
from typing import Any, Dict, List, Optional, Union

import numpy as np
import torch

from ...audio_utils import mel_filter_bank, spectrogram, window_function
from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
from ...feature_extraction_utils import BatchFeature
from ...utils import TensorType, logging


__UpperCAmelCase : int 			=				logging.get_logger(__name__)



class    UpperCAmelCase_	(							lowercase_):
       '''simple docstring'''
       __UpperCamelCase      :     int							=					['''input_features''', '''is_longer''']






       def __init__(     self ,					__SCREAMING_SNAKE_CASE=64 ,					__SCREAMING_SNAKE_CASE=48_000 ,					__SCREAMING_SNAKE_CASE=480 ,					__SCREAMING_SNAKE_CASE=10 ,					__SCREAMING_SNAKE_CASE=1_024 ,					__SCREAMING_SNAKE_CASE=0.0 ,					__SCREAMING_SNAKE_CASE=False ,					__SCREAMING_SNAKE_CASE = 0 ,					__SCREAMING_SNAKE_CASE = 14_000 ,					__SCREAMING_SNAKE_CASE = None ,					__SCREAMING_SNAKE_CASE = "fusion" ,					__SCREAMING_SNAKE_CASE = "repeatpad" ,					**__SCREAMING_SNAKE_CASE ,					):




              """simple docstring"""




              super().__init__(
                  feature_size=__SCREAMING_SNAKE_CASE ,					sampling_rate=__SCREAMING_SNAKE_CASE ,					padding_value=__SCREAMING_SNAKE_CASE ,					return_attention_mask=__SCREAMING_SNAKE_CASE ,					**__SCREAMING_SNAKE_CASE ,					)
              UpperCamelCase    :	Dict   	=		top_db
              UpperCamelCase    :	Union[str, Any]   	=		truncation
              UpperCamelCase    :	Optional[Any]   	=		padding
              UpperCamelCase    :	Dict   	=		fft_window_size
              UpperCamelCase    :	Union[str, Any]   	=		(fft_window_size >> 1) + 1
              UpperCamelCase    :	Union[str, Any]   	=		hop_length
              UpperCamelCase    :	List[str]   	=		max_length_s
              UpperCamelCase    :	Tuple   	=		max_length_s * sampling_rate
              UpperCamelCase    :	str   	=		sampling_rate
              UpperCamelCase    :	Optional[Any]   	=		frequency_min
              UpperCamelCase    :	str   	=		frequency_max
              UpperCamelCase    :	Union[str, Any]   	=		mel_filter_bank(
                  num_frequency_bins=self.nb_frequency_bins ,					num_mel_filters=__SCREAMING_SNAKE_CASE ,					min_frequency=__SCREAMING_SNAKE_CASE ,					max_frequency=__SCREAMING_SNAKE_CASE ,					sampling_rate=__SCREAMING_SNAKE_CASE ,					norm=__SCREAMING_SNAKE_CASE ,					mel_scale='''htk''' ,					)
              UpperCamelCase    :	List[Any]   	=		mel_filter_bank(
                  num_frequency_bins=self.nb_frequency_bins ,					num_mel_filters=__SCREAMING_SNAKE_CASE ,					min_frequency=__SCREAMING_SNAKE_CASE ,					max_frequency=__SCREAMING_SNAKE_CASE ,					sampling_rate=__SCREAMING_SNAKE_CASE ,					norm='''slaney''' ,					mel_scale='''slaney''' ,					)






       def  _lowercase   (     self						):




              """simple docstring"""




              UpperCamelCase    :	Dict   	=		copy.deepcopy(self.__dict__						)
              UpperCamelCase    :	int   	=		self.__class__.__name__
              if "mel_filters" in output:
                     del output["mel_filters"]
              if "mel_filters_slaney" in output:
                     del output["mel_filters_slaney"]
              return output






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE = None						):




              """simple docstring"""




              UpperCamelCase    :	Tuple   	=		spectrogram(
                  __SCREAMING_SNAKE_CASE ,					window_function(self.fft_window_size ,					'''hann'''						) ,					frame_length=self.fft_window_size ,					hop_length=self.hop_length ,					power=2.0 ,					mel_filters=__SCREAMING_SNAKE_CASE ,					log_mel='''dB''' ,					)
              return log_mel_spectrogram.T






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              UpperCamelCase    :	Optional[Any]   	=		np.array_split(list(range(0 ,					total_frames - chunk_frames + 1						)						) ,					3						)
              if len(ranges[1]						) == 0:
                     # if the audio is too short, we just use the first chunk
                     UpperCamelCase    :	Tuple   	=		[0]
              if len(ranges[2]						) == 0:
                     # if the audio is too short, we just use the first chunk
                     UpperCamelCase    :	Dict   	=		[0]
              # randomly choose index for each part
              UpperCamelCase    :	Any   	=		np.random.choice(ranges[0]						)
              UpperCamelCase    :	List[Any]   	=		np.random.choice(ranges[1]						)
              UpperCamelCase    :	List[str]   	=		np.random.choice(ranges[2]						)

              UpperCamelCase    :	List[str]   	=		mel[idx_front : idx_front + chunk_frames, :]
              UpperCamelCase    :	List[str]   	=		mel[idx_middle : idx_middle + chunk_frames, :]
              UpperCamelCase    :	List[str]   	=		mel[idx_back : idx_back + chunk_frames, :]

              UpperCamelCase    :	Any   	=		torch.tensor(mel[None, None, :]						)
              UpperCamelCase    :	Any   	=		torch.nn.functional.interpolate(
                  __SCREAMING_SNAKE_CASE ,					size=[chunk_frames, 64] ,					mode='''bilinear''' ,					align_corners=__SCREAMING_SNAKE_CASE						)
              UpperCamelCase    :	Union[str, Any]   	=		mel_shrink[0][0].numpy()
              UpperCamelCase    :	Optional[Any]   	=		np.stack([mel_shrink, mel_chunk_front, mel_chunk_middle, mel_chunk_back] ,					axis=0						)
              return mel_fusion






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              if waveform.shape[0] > max_length:
                     if truncation == "rand_trunc":
                            UpperCamelCase    :	str   	=		True
                            # random crop to max_length (for compatibility) -> this should be handled by self.pad
                            UpperCamelCase    :	List[str]   	=		len(__SCREAMING_SNAKE_CASE						) - max_length
                            UpperCamelCase    :	Optional[int]   	=		np.random.randint(0 ,					overflow + 1						)
                            UpperCamelCase    :	Union[str, Any]   	=		waveform[idx : idx + max_length]
                            UpperCamelCase    :	List[Any]   	=		self._np_extract_fbank_features(__SCREAMING_SNAKE_CASE ,					self.mel_filters_slaney						)[None, :]
                     elif truncation == "fusion":
                            UpperCamelCase    :	str   	=		self._np_extract_fbank_features(__SCREAMING_SNAKE_CASE ,					self.mel_filters						)
                            UpperCamelCase    :	Optional[Any]   	=		max_length // self.hop_length + 1  # the +1 related to how the spectrogram is computed
                            UpperCamelCase    :	Optional[Any]   	=		mel.shape[0]
                            if chunk_frames == total_frames:
                                   # there is a corner case where the audio length is larger than max_length but smaller than max_length+hop_length.
                                   # In this case, we just use the whole audio.
                                   UpperCamelCase    :	Any   	=		np.stack([mel, mel, mel, mel] ,					axis=0						)
                                   UpperCamelCase    :	List[Any]   	=		False
                            else:
                                   UpperCamelCase    :	str   	=		self._random_mel_fusion(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)
                                   UpperCamelCase    :	List[str]   	=		True
                     else:
                            raise NotImplementedError(f"""data_truncating {truncation} not implemented"""						)

              else:
                     UpperCamelCase    :	List[str]   	=		False
                     # only use repeat as a new possible value for padding. you repeat the audio before applying the usual max_length padding
                     if waveform.shape[0] < max_length:
                            if padding == "repeat":
                                   UpperCamelCase    :	List[str]   	=		int(max_length / len(__SCREAMING_SNAKE_CASE						)						)
                                   UpperCamelCase    :	int   	=		np.stack(np.tile(__SCREAMING_SNAKE_CASE ,					n_repeat + 1						)						)[:max_length]
                            if padding == "repeatpad":
                                   UpperCamelCase    :	Union[str, Any]   	=		int(max_length / len(__SCREAMING_SNAKE_CASE						)						)
                                   UpperCamelCase    :	List[str]   	=		np.stack(np.tile(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)						)
                            UpperCamelCase    :	Any   	=		np.pad(__SCREAMING_SNAKE_CASE ,					(0, max_length - waveform.shape[0]) ,					mode='''constant''' ,					constant_values=0						)

                     if truncation == "fusion":
                            UpperCamelCase    :	Tuple   	=		self._np_extract_fbank_features(__SCREAMING_SNAKE_CASE ,					self.mel_filters						)
                            UpperCamelCase    :	int   	=		np.stack([input_mel, input_mel, input_mel, input_mel] ,					axis=0						)
                     else:
                            UpperCamelCase    :	Dict   	=		self._np_extract_fbank_features(__SCREAMING_SNAKE_CASE ,					self.mel_filters_slaney						)[None, :]

              return input_mel, longer






       def __call__(     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE = None ,					__SCREAMING_SNAKE_CASE = None ,					__SCREAMING_SNAKE_CASE = None ,					__SCREAMING_SNAKE_CASE = None ,					__SCREAMING_SNAKE_CASE = None ,					**__SCREAMING_SNAKE_CASE ,					):




              """simple docstring"""




              UpperCamelCase    :	List[Any]   	=		truncation if truncation is not None else self.truncation
              UpperCamelCase    :	List[str]   	=		padding if padding else self.padding

              if sampling_rate is not None:
                     if sampling_rate != self.sampling_rate:
                            raise ValueError(
                                f"""The model corresponding to this feature extractor: {self.__class__.__name__} was trained using a"""
                                f""" sampling rate of {self.sampling_rate}. Please make sure that the provided `raw_speech` input"""
                                f""" was sampled with {self.sampling_rate} and not {sampling_rate}."""						)
              else:
                     logger.warning(
                         '''It is strongly recommended to pass the `sampling_rate` argument to this function. '''
                         '''Failing to do so can result in silent errors that might be hard to debug.'''						)

              UpperCamelCase    :	Any   	=		isinstance(__SCREAMING_SNAKE_CASE ,					np.ndarray						) and len(raw_speech.shape						) > 1
              if is_batched_numpy and len(raw_speech.shape						) > 2:
                     raise ValueError(f"""Only mono-channel audio is supported for input to {self}"""						)
              UpperCamelCase    :	int   	=		is_batched_numpy or (
                  isinstance(__SCREAMING_SNAKE_CASE ,					(list, tuple)						) and (isinstance(raw_speech[0] ,					(np.ndarray, tuple, list)						))
              )

              if is_batched:
                     UpperCamelCase    :	int   	=		[np.asarray(__SCREAMING_SNAKE_CASE ,					dtype=np.floataa						) for speech in raw_speech]
              elif not is_batched and not isinstance(__SCREAMING_SNAKE_CASE ,					np.ndarray						):
                     UpperCamelCase    :	Optional[int]   	=		np.asarray(__SCREAMING_SNAKE_CASE ,					dtype=np.floataa						)
              elif isinstance(__SCREAMING_SNAKE_CASE ,					np.ndarray						) and raw_speech.dtype is np.dtype(np.floataa						):
                     UpperCamelCase    :	Optional[Any]   	=		raw_speech.astype(np.floataa						)

              # always return batch
              if not is_batched:
                     UpperCamelCase    :	Dict   	=		[np.asarray(__SCREAMING_SNAKE_CASE						)]

              # convert to mel spectrogram, truncate and pad if needed.
              UpperCamelCase    :	int   	=		[
                  self._get_input_mel(__SCREAMING_SNAKE_CASE ,					max_length if max_length else self.nb_max_samples ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)
                  for waveform in raw_speech
              ]

              UpperCamelCase    :	Dict   	=		[]
              UpperCamelCase    :	int   	=		[]
              for mel, longer in padded_inputs:
                     input_mel.append(__SCREAMING_SNAKE_CASE						)
                     is_longer.append(__SCREAMING_SNAKE_CASE						)

              if truncation == "fusion" and sum(__SCREAMING_SNAKE_CASE						) == 0:
                     # if no audio is longer than 10s, then randomly select one audio to be longer
                     UpperCamelCase    :	int   	=		np.random.randint(0 ,					len(__SCREAMING_SNAKE_CASE						)						)
                     UpperCamelCase    :	List[str]   	=		True

              if isinstance(input_mel[0] ,					__SCREAMING_SNAKE_CASE						):
                     UpperCamelCase    :	Optional[int]   	=		[np.asarray(__SCREAMING_SNAKE_CASE ,					dtype=np.floataa						) for feature in input_mel]

              # is_longer is a list of bool
              UpperCamelCase    :	int   	=		[[longer] for longer in is_longer]

              UpperCamelCase    :	Optional[Any]   	=		{'''input_features''': input_mel, '''is_longer''': is_longer}
              UpperCamelCase    :	List[Any]   	=		BatchFeature(__SCREAMING_SNAKE_CASE						)

              if return_tensors is not None:
                     UpperCamelCase    :	int   	=		input_features.convert_to_tensors(__SCREAMING_SNAKE_CASE						)

              return input_features









import json
import os
import shutil
import warnings
from argparse import ArgumentParser, Namespace
from pathlib import Path
from typing import List

from ..utils import logging
from . import BaseTransformersCLICommand


try:
  from cookiecutter.main import cookiecutter

  __UpperCAmelCase : List[Any] 			=				True
except ImportError:
  __UpperCAmelCase : List[str] 			=				False

__UpperCAmelCase : Any 			=				logging.get_logger(__name__)  # pylint: disable=invalid-name


def      a	(							SCREAMING_SNAKE_CASE_      :		Namespace       ):






       """simple docstring"""





       return AddNewModelCommand(args.testing							,			args.testing_file							,			path=args.path       )



class    UpperCAmelCase_	(							_a):
       '''simple docstring'''






       @staticmethod
       def  _lowercase   (     __SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              UpperCamelCase    :	List[Any]   	=		parser.add_parser('''add-new-model'''						)
              add_new_model_parser.add_argument('''--testing''' ,					action='''store_true''' ,					help='''If in testing mode.'''						)
              add_new_model_parser.add_argument('''--testing_file''' ,					type=__SCREAMING_SNAKE_CASE ,					help='''Configuration file on which to run.'''						)
              add_new_model_parser.add_argument(
                  '''--path''' ,					type=__SCREAMING_SNAKE_CASE ,					help='''Path to cookiecutter. Should only be used for testing purposes.'''						)
              add_new_model_parser.set_defaults(func=__SCREAMING_SNAKE_CASE						)






       def __init__(     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE=None ,					*__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              UpperCamelCase    :	Tuple   	=		testing
              UpperCamelCase    :	Any   	=		testing_file
              UpperCamelCase    :	Dict   	=		path






       def  _lowercase   (     self						):




              """simple docstring"""




              warnings.warn(
                  '''The command `transformers-cli add-new-model` is deprecated and will be removed in v5 of Transformers. '''
                  '''It is not actively maintained anymore, so might give a result that won\'t pass all tests and quality '''
                  '''checks, you should use `transformers-cli add-new-model-like` instead.'''						)
              if not _has_cookiecutter:
                     raise ImportError(
                         '''Model creation dependencies are required to use the `add_new_model` command. Install them by running '''
                         '''the following at the root of your `transformers` clone:\n\n\t$ pip install -e .[modelcreation]\n'''						)
              # Ensure that there is no other `cookiecutter-template-xxx` directory in the current working directory
              UpperCamelCase    :	List[str]   	=		[directory for directory in os.listdir() if '''cookiecutter-template-''' == directory[:22]]
              if len(__SCREAMING_SNAKE_CASE						) > 0:
                     raise ValueError(
                         '''Several directories starting with `cookiecutter-template-` in current working directory. '''
                         '''Please clean your directory by removing all folders starting with `cookiecutter-template-` or '''
                         '''change your working directory.'''						)

              UpperCamelCase    :	Dict   	=		(
                  Path(__SCREAMING_SNAKE_CASE						).parent.parent.parent.parent if self._path is None else Path(self._path						).parent.parent
              )
              UpperCamelCase    :	List[Any]   	=		path_to_transformer_root / '''templates''' / '''adding_a_new_model'''

              # Execute cookiecutter
              if not self._testing:
                     cookiecutter(str(__SCREAMING_SNAKE_CASE						)						)
              else:
                     with open(self._testing_file ,					'''r'''						) as configuration_file:
                            UpperCamelCase    :	Tuple   	=		json.load(__SCREAMING_SNAKE_CASE						)

                     cookiecutter(
                         str(path_to_cookiecutter if self._path is None else self._path						) ,					no_input=__SCREAMING_SNAKE_CASE ,					extra_context=__SCREAMING_SNAKE_CASE ,					)

              UpperCamelCase    :	Dict   	=		[directory for directory in os.listdir() if '''cookiecutter-template-''' in directory[:22]][0]

              # Retrieve configuration
              with open(directory + '''/configuration.json''' ,					'''r'''						) as configuration_file:
                     UpperCamelCase    :	Tuple   	=		json.load(__SCREAMING_SNAKE_CASE						)

              UpperCamelCase    :	Dict   	=		configuration['''lowercase_modelname''']
              UpperCamelCase    :	int   	=		configuration['''generate_tensorflow_pytorch_and_flax''']
              os.remove(f"""{directory}/configuration.json"""						)

              UpperCamelCase    :	str   	=		'''PyTorch''' in generate_tensorflow_pytorch_and_flax
              UpperCamelCase    :	Any   	=		'''TensorFlow''' in generate_tensorflow_pytorch_and_flax
              UpperCamelCase    :	Union[str, Any]   	=		'''Flax''' in generate_tensorflow_pytorch_and_flax

              UpperCamelCase    :	Optional[Any]   	=		f"""{path_to_transformer_root}/src/transformers/models/{lowercase_model_name}"""
              os.makedirs(__SCREAMING_SNAKE_CASE ,					exist_ok=__SCREAMING_SNAKE_CASE						)
              os.makedirs(f"""{path_to_transformer_root}/tests/models/{lowercase_model_name}""" ,					exist_ok=__SCREAMING_SNAKE_CASE						)

              # Tests require submodules as they have parent imports
              with open(f"""{path_to_transformer_root}/tests/models/{lowercase_model_name}/__init__.py""" ,					'''w'''						):
                     pass

              shutil.move(
                  f"""{directory}/__init__.py""" ,					f"""{model_dir}/__init__.py""" ,					)
              shutil.move(
                  f"""{directory}/configuration_{lowercase_model_name}.py""" ,					f"""{model_dir}/configuration_{lowercase_model_name}.py""" ,					)

              def remove_copy_lines(__SCREAMING_SNAKE_CASE						):
                     with open(__SCREAMING_SNAKE_CASE ,					'''r'''						) as f:
                            UpperCamelCase    :	Any   	=		f.readlines()
                     with open(__SCREAMING_SNAKE_CASE ,					'''w'''						) as f:
                            for line in lines:
                                   if "# Copied from transformers." not in line:
                                          f.write(__SCREAMING_SNAKE_CASE						)

              if output_pytorch:
                     if not self._testing:
                            remove_copy_lines(f"""{directory}/modeling_{lowercase_model_name}.py"""						)

                     shutil.move(
                         f"""{directory}/modeling_{lowercase_model_name}.py""" ,					f"""{model_dir}/modeling_{lowercase_model_name}.py""" ,					)

                     shutil.move(
                         f"""{directory}/test_modeling_{lowercase_model_name}.py""" ,					f"""{path_to_transformer_root}/tests/models/{lowercase_model_name}/test_modeling_{lowercase_model_name}.py""" ,					)
              else:
                     os.remove(f"""{directory}/modeling_{lowercase_model_name}.py"""						)
                     os.remove(f"""{directory}/test_modeling_{lowercase_model_name}.py"""						)

              if output_tensorflow:
                     if not self._testing:
                            remove_copy_lines(f"""{directory}/modeling_tf_{lowercase_model_name}.py"""						)

                     shutil.move(
                         f"""{directory}/modeling_tf_{lowercase_model_name}.py""" ,					f"""{model_dir}/modeling_tf_{lowercase_model_name}.py""" ,					)

                     shutil.move(
                         f"""{directory}/test_modeling_tf_{lowercase_model_name}.py""" ,					f"""{path_to_transformer_root}/tests/models/{lowercase_model_name}/test_modeling_tf_{lowercase_model_name}.py""" ,					)
              else:
                     os.remove(f"""{directory}/modeling_tf_{lowercase_model_name}.py"""						)
                     os.remove(f"""{directory}/test_modeling_tf_{lowercase_model_name}.py"""						)

              if output_flax:
                     if not self._testing:
                            remove_copy_lines(f"""{directory}/modeling_flax_{lowercase_model_name}.py"""						)

                     shutil.move(
                         f"""{directory}/modeling_flax_{lowercase_model_name}.py""" ,					f"""{model_dir}/modeling_flax_{lowercase_model_name}.py""" ,					)

                     shutil.move(
                         f"""{directory}/test_modeling_flax_{lowercase_model_name}.py""" ,					f"""{path_to_transformer_root}/tests/models/{lowercase_model_name}/test_modeling_flax_{lowercase_model_name}.py""" ,					)
              else:
                     os.remove(f"""{directory}/modeling_flax_{lowercase_model_name}.py"""						)
                     os.remove(f"""{directory}/test_modeling_flax_{lowercase_model_name}.py"""						)

              shutil.move(
                  f"""{directory}/{lowercase_model_name}.md""" ,					f"""{path_to_transformer_root}/docs/source/en/model_doc/{lowercase_model_name}.md""" ,					)

              shutil.move(
                  f"""{directory}/tokenization_{lowercase_model_name}.py""" ,					f"""{model_dir}/tokenization_{lowercase_model_name}.py""" ,					)

              shutil.move(
                  f"""{directory}/tokenization_fast_{lowercase_model_name}.py""" ,					f"""{model_dir}/tokenization_{lowercase_model_name}_fast.py""" ,					)

              from os import fdopen, remove
              from shutil import copymode, move
              from tempfile import mkstemp

              def replace(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						):
                     # Create temp file
                     UpperCamelCase	, UpperCamelCase    :	Optional[Any]   	=		mkstemp()
                     UpperCamelCase    :	Tuple   	=		False
                     with fdopen(__SCREAMING_SNAKE_CASE ,					'''w'''						) as new_file:
                            with open(__SCREAMING_SNAKE_CASE						) as old_file:
                                   for line in old_file:
                                          new_file.write(__SCREAMING_SNAKE_CASE						)
                                          if line_to_copy_below in line:
                                                 UpperCamelCase    :	Optional[int]   	=		True
                                                 for line_to_copy in lines_to_copy:
                                                        new_file.write(__SCREAMING_SNAKE_CASE						)

                     if not line_found:
                            raise ValueError(f"""Line {line_to_copy_below} was not found in file."""						)

                     # Copy the file permissions from the old file to the new file
                     copymode(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)
                     # Remove original file
                     remove(__SCREAMING_SNAKE_CASE						)
                     # Move new file
                     move(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)

              def skip_units(__SCREAMING_SNAKE_CASE						):
                     return (
                         ("generating PyTorch" in line and not output_pytorch)
                         or ("generating TensorFlow" in line and not output_tensorflow)
                         or ("generating Flax" in line and not output_flax)
                     )

              def replace_in_files(__SCREAMING_SNAKE_CASE						):
                     with open(__SCREAMING_SNAKE_CASE						) as datafile:
                            UpperCamelCase    :	int   	=		[]
                            UpperCamelCase    :	Dict   	=		False
                            UpperCamelCase    :	List[Any]   	=		False
                            for line in datafile:
                                   if "# To replace in: " in line and "##" not in line:
                                          UpperCamelCase    :	Dict   	=		line.split('''"'''						)[1]
                                          UpperCamelCase    :	int   	=		skip_units(__SCREAMING_SNAKE_CASE						)
                                   elif "# Below: " in line and "##" not in line:
                                          UpperCamelCase    :	Dict   	=		line.split('''"'''						)[1]
                                          UpperCamelCase    :	List[str]   	=		skip_units(__SCREAMING_SNAKE_CASE						)
                                   elif "# End." in line and "##" not in line:
                                          if not skip_file and not skip_snippet:
                                                 replace(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						)

                                          UpperCamelCase    :	Dict   	=		[]
                                   elif "# Replace with" in line and "##" not in line:
                                          UpperCamelCase    :	Tuple   	=		[]
                                   elif "##" not in line:
                                          lines_to_copy.append(__SCREAMING_SNAKE_CASE						)

                     remove(__SCREAMING_SNAKE_CASE						)

              replace_in_files(f"""{directory}/to_replace_{lowercase_model_name}.py"""						)
              os.rmdir(__SCREAMING_SNAKE_CASE						)

