
"""simple docstring"""




import tempfile
import unittest

import numpy as np

from diffusers import (
    DDIMScheduler,
    DPMSolverMultistepScheduler,
    EulerAncestralDiscreteScheduler,
    EulerDiscreteScheduler,
    LMSDiscreteScheduler,
    OnnxStableDiffusionPipeline,
    PNDMScheduler,
)
from diffusers.utils.testing_utils import is_onnx_available, nightly, require_onnxruntime, require_torch_gpu

from ..test_pipelines_onnx_common import OnnxPipelineTesterMixin


if is_onnx_available():
  import onnxruntime as ort


class 			__magic_name__       (       SCREAMING_SNAKE_CASE__   ,					unittest.TestCase ):
       UpperCamelCase_   =		'''hf-internal-testing/tiny-random-OnnxStableDiffusionPipeline'''
       def 							lowercase_							(     self ,				A_=0       )     ->	Union[str, Any]:





         """simple docstring"""




         _lowercase:			Union[str, Any]       =     np.random.RandomState(A_       )
         _lowercase:			Any       =     {
             '''prompt''': '''A painting of a squirrel eating a burger''',
             '''generator''': generator,
             '''num_inference_steps''': 2,
             '''guidance_scale''': 7.5,
             '''output_type''': '''numpy''',
         }
         return inputs
       def 							lowercase_							(     self       )     ->	Optional[int]:





         """simple docstring"""




         _lowercase:			Any       =     OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint ,				provider='''CPUExecutionProvider'''       )
         pipe.set_progress_bar_config(disable=A_       )

         _lowercase:			List[str]       =     self.get_dummy_inputs()
         _lowercase:			Union[str, Any]       =     pipe(**A_       ).images
         _lowercase:			int       =     image[0, -3:, -3:, -1]

         assert image.shape == (1, 128, 128, 3)
         _lowercase:			Dict       =     np.array([0.6_50_72, 0.5_84_92, 0.4_82_19, 0.5_55_21, 0.5_31_80, 0.5_59_39, 0.5_06_97, 0.3_98_00, 0.4_64_55]       )

         assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1E-2
       def 							lowercase_							(     self       )     ->	str:





         """simple docstring"""




         _lowercase:			Optional[int]       =     OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint ,				provider='''CPUExecutionProvider'''       )
         _lowercase:			Any       =     PNDMScheduler.from_config(pipe.scheduler.config ,				skip_prk_steps=A_       )
         pipe.set_progress_bar_config(disable=A_       )

         _lowercase:			Tuple       =     self.get_dummy_inputs()
         _lowercase:			Optional[int]       =     pipe(**A_       ).images
         _lowercase:			Optional[Any]       =     image[0, -3:, -3:, -1]

         assert image.shape == (1, 128, 128, 3)
         _lowercase:			Union[str, Any]       =     np.array([0.6_58_63, 0.5_94_25, 0.4_93_26, 0.5_63_13, 0.5_38_75, 0.5_66_27, 0.5_10_65, 0.3_97_77, 0.4_63_30]       )

         assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1E-2
       def 							lowercase_							(     self       )     ->	Any:





         """simple docstring"""




         _lowercase:			str       =     OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint ,				provider='''CPUExecutionProvider'''       )
         _lowercase:			int       =     LMSDiscreteScheduler.from_config(pipe.scheduler.config       )
         pipe.set_progress_bar_config(disable=A_       )

         _lowercase:			List[Any]       =     self.get_dummy_inputs()
         _lowercase:			Optional[int]       =     pipe(**A_       ).images
         _lowercase:			str       =     image[0, -3:, -3:, -1]

         assert image.shape == (1, 128, 128, 3)
         _lowercase:			str       =     np.array([0.5_37_55, 0.6_07_86, 0.4_74_02, 0.4_94_88, 0.5_18_69, 0.4_98_19, 0.4_79_85, 0.3_89_57, 0.4_42_79]       )

         assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1E-2
       def 							lowercase_							(     self       )     ->	Dict:





         """simple docstring"""




         _lowercase:			Any       =     OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint ,				provider='''CPUExecutionProvider'''       )
         _lowercase:			Tuple       =     EulerDiscreteScheduler.from_config(pipe.scheduler.config       )
         pipe.set_progress_bar_config(disable=A_       )

         _lowercase:			int       =     self.get_dummy_inputs()
         _lowercase:			Tuple       =     pipe(**A_       ).images
         _lowercase:			Tuple       =     image[0, -3:, -3:, -1]

         assert image.shape == (1, 128, 128, 3)
         _lowercase:			List[Any]       =     np.array([0.5_37_55, 0.6_07_86, 0.4_74_02, 0.4_94_88, 0.5_18_69, 0.4_98_19, 0.4_79_85, 0.3_89_57, 0.4_42_79]       )

         assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1E-2
       def 							lowercase_							(     self       )     ->	Union[str, Any]:





         """simple docstring"""




         _lowercase:			Union[str, Any]       =     OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint ,				provider='''CPUExecutionProvider'''       )
         _lowercase:			Optional[int]       =     EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config       )
         pipe.set_progress_bar_config(disable=A_       )

         _lowercase:			int       =     self.get_dummy_inputs()
         _lowercase:			List[Any]       =     pipe(**A_       ).images
         _lowercase:			Optional[Any]       =     image[0, -3:, -3:, -1]

         assert image.shape == (1, 128, 128, 3)
         _lowercase:			Optional[int]       =     np.array([0.5_38_17, 0.6_08_12, 0.4_73_84, 0.4_95_30, 0.5_18_94, 0.4_98_14, 0.4_79_84, 0.3_89_58, 0.4_42_71]       )

         assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1E-2
       def 							lowercase_							(     self       )     ->	Any:





         """simple docstring"""




         _lowercase:			int       =     OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint ,				provider='''CPUExecutionProvider'''       )
         _lowercase:			List[Any]       =     DPMSolverMultistepScheduler.from_config(pipe.scheduler.config       )
         pipe.set_progress_bar_config(disable=A_       )

         _lowercase:			Dict       =     self.get_dummy_inputs()
         _lowercase:			List[Any]       =     pipe(**A_       ).images
         _lowercase:			List[Any]       =     image[0, -3:, -3:, -1]

         assert image.shape == (1, 128, 128, 3)
         _lowercase:			List[Any]       =     np.array([0.5_38_95, 0.6_08_08, 0.4_79_33, 0.4_96_08, 0.5_18_86, 0.4_99_50, 0.4_80_53, 0.3_89_57, 0.4_42_00]       )

         assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1E-2
       def 							lowercase_							(     self       )     ->	List[Any]:





         """simple docstring"""




         _lowercase:			Tuple       =     OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint ,				provider='''CPUExecutionProvider'''       )
         pipe.set_progress_bar_config(disable=A_       )

         _lowercase:			List[str]       =     self.get_dummy_inputs()
         _lowercase:			Optional[Any]       =     3 * [inputs['''prompt''']]

         # forward
         _lowercase:			int       =     pipe(**A_       )
         _lowercase:			List[str]       =     output.images[0, -3:, -3:, -1]

         _lowercase:			Union[str, Any]       =     self.get_dummy_inputs()
         _lowercase:			Any       =     3 * [inputs.pop('''prompt'''       )]

         _lowercase:			Optional[int]       =     pipe.tokenizer(
             A_ ,				padding='''max_length''' ,				max_length=pipe.tokenizer.model_max_length ,				truncation=A_ ,				return_tensors='''np''' ,				)
         _lowercase:			List[str]       =     text_inputs['''input_ids''']

         _lowercase:			Union[str, Any]       =     pipe.text_encoder(input_ids=text_inputs.astype(np.intaa       )       )[0]

         _lowercase:			Optional[int]       =     prompt_embeds

         # forward
         _lowercase:			Dict       =     pipe(**A_       )
         _lowercase:			List[str]       =     output.images[0, -3:, -3:, -1]

         assert np.abs(image_slice_a.flatten() - image_slice_a.flatten()       ).max() < 1E-4



       def 							lowercase_							(     self       )     ->	Optional[int]:





         """simple docstring"""




         _lowercase:			Union[str, Any]       =     OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint ,				provider='''CPUExecutionProvider'''       )
         pipe.set_progress_bar_config(disable=A_       )

         _lowercase:			int       =     self.get_dummy_inputs()
         _lowercase:			Any       =     3 * ['''this is a negative prompt''']
         _lowercase:			Any       =     negative_prompt
         _lowercase:			List[Any]       =     3 * [inputs['''prompt''']]

         # forward
         _lowercase:			Dict       =     pipe(**A_       )
         _lowercase:			Any       =     output.images[0, -3:, -3:, -1]

         _lowercase:			Optional[Any]       =     self.get_dummy_inputs()
         _lowercase:			str       =     3 * [inputs.pop('''prompt'''       )]

         _lowercase:			List[Any]       =     []
         for p in [prompt, negative_prompt]:
           _lowercase:			Any       =     pipe.tokenizer(
               A_ ,				padding='''max_length''' ,				max_length=pipe.tokenizer.model_max_length ,				truncation=A_ ,				return_tensors='''np''' ,				)
           _lowercase:			int       =     text_inputs['''input_ids''']

           embeds.append(pipe.text_encoder(input_ids=text_inputs.astype(np.intaa       )       )[0]       )

         _lowercase ,				_lowercase:			int       =     embeds

         # forward
         _lowercase:			Any       =     pipe(**A_       )
         _lowercase:			Any       =     output.images[0, -3:, -3:, -1]

         assert np.abs(image_slice_a.flatten() - image_slice_a.flatten()       ).max() < 1E-4


@nightly
@require_onnxruntime
@require_torch_gpu
class 			__magic_name__       (       unittest.TestCase ):
       @property
       def 							lowercase_							(     self       )     ->	str:





         """simple docstring"""




         return (
             "CUDAExecutionProvider",
             {
                 "gpu_mem_limit": "15000000000",  # 15GB
                 "arena_extend_strategy": "kSameAsRequested",
             },
         )
       @property
       def 							lowercase_							(     self       )     ->	Optional[int]:





         """simple docstring"""




         _lowercase:			str       =     ort.SessionOptions()
         _lowercase:			Tuple       =     False
         return options
       def 							lowercase_							(     self       )     ->	Optional[Any]:





         """simple docstring"""




         _lowercase:			Dict       =     OnnxStableDiffusionPipeline.from_pretrained(
             '''CompVis/stable-diffusion-v1-4''' ,				revision='''onnx''' ,				safety_checker=A_ ,				feature_extractor=A_ ,				provider=self.gpu_provider ,				sess_options=self.gpu_options ,				)
         sd_pipe.set_progress_bar_config(disable=A_       )

         _lowercase:			Optional[Any]       =     '''A painting of a squirrel eating a burger'''
         np.random.seed(0       )
         _lowercase:			Optional[int]       =     sd_pipe([prompt] ,				guidance_scale=6.0 ,				num_inference_steps=10 ,				output_type='''np'''       )
         _lowercase:			Tuple       =     output.images

         _lowercase:			Dict       =     image[0, -3:, -3:, -1]

         assert image.shape == (1, 512, 512, 3)
         _lowercase:			Union[str, Any]       =     np.array([0.04_52, 0.03_90, 0.00_87, 0.03_50, 0.06_17, 0.03_64, 0.05_44, 0.05_23, 0.07_20]       )

         assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1E-3
       def 							lowercase_							(     self       )     ->	Any:





         """simple docstring"""




         _lowercase:			Tuple       =     DDIMScheduler.from_pretrained(
             '''runwayml/stable-diffusion-v1-5''' ,				subfolder='''scheduler''' ,				revision='''onnx'''       )
         _lowercase:			int       =     OnnxStableDiffusionPipeline.from_pretrained(
             '''runwayml/stable-diffusion-v1-5''' ,				revision='''onnx''' ,				scheduler=A_ ,				safety_checker=A_ ,				feature_extractor=A_ ,				provider=self.gpu_provider ,				sess_options=self.gpu_options ,				)
         sd_pipe.set_progress_bar_config(disable=A_       )

         _lowercase:			int       =     '''open neural network exchange'''
         _lowercase:			List[Any]       =     np.random.RandomState(0       )
         _lowercase:			Union[str, Any]       =     sd_pipe([prompt] ,				guidance_scale=7.5 ,				num_inference_steps=10 ,				generator=A_ ,				output_type='''np'''       )
         _lowercase:			List[Any]       =     output.images
         _lowercase:			Tuple       =     image[0, -3:, -3:, -1]

         assert image.shape == (1, 512, 512, 3)
         _lowercase:			Any       =     np.array([0.28_67, 0.19_74, 0.14_81, 0.72_94, 0.72_51, 0.66_67, 0.41_94, 0.56_42, 0.64_86]       )

         assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1E-3
       def 							lowercase_							(     self       )     ->	int:





         """simple docstring"""




         _lowercase:			int       =     LMSDiscreteScheduler.from_pretrained(
             '''runwayml/stable-diffusion-v1-5''' ,				subfolder='''scheduler''' ,				revision='''onnx'''       )
         _lowercase:			str       =     OnnxStableDiffusionPipeline.from_pretrained(
             '''runwayml/stable-diffusion-v1-5''' ,				revision='''onnx''' ,				scheduler=A_ ,				safety_checker=A_ ,				feature_extractor=A_ ,				provider=self.gpu_provider ,				sess_options=self.gpu_options ,				)
         sd_pipe.set_progress_bar_config(disable=A_       )

         _lowercase:			Optional[Any]       =     '''open neural network exchange'''
         _lowercase:			Tuple       =     np.random.RandomState(0       )
         _lowercase:			Optional[int]       =     sd_pipe([prompt] ,				guidance_scale=7.5 ,				num_inference_steps=10 ,				generator=A_ ,				output_type='''np'''       )
         _lowercase:			Dict       =     output.images
         _lowercase:			Optional[Any]       =     image[0, -3:, -3:, -1]

         assert image.shape == (1, 512, 512, 3)
         _lowercase:			List[Any]       =     np.array([0.23_06, 0.19_59, 0.15_93, 0.65_49, 0.63_94, 0.54_08, 0.50_65, 0.60_10, 0.61_61]       )

         assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1E-3
       def 							lowercase_							(     self       )     ->	Tuple:





         """simple docstring"""




         _lowercase:			Any       =     0

         def test_callback_fn(A_ ,				A_ ,				A_       ) -> None:
           _lowercase:			Tuple       =     True
           nonlocal number_of_steps
           number_of_steps += 1
           if step == 0:
             assert latents.shape == (1, 4, 64, 64)
             _lowercase:			Any       =     latents[0, -3:, -3:, -1]
             _lowercase:			str       =     np.array(
                 [-0.67_72, -0.38_35, -1.24_56, 0.19_05, -1.09_74, 0.69_67, -1.93_53, 0.01_78, 1.01_67]       )

             assert np.abs(latents_slice.flatten() - expected_slice       ).max() < 1E-3
           elif step == 5:
             assert latents.shape == (1, 4, 64, 64)
             _lowercase:			str       =     latents[0, -3:, -3:, -1]
             _lowercase:			str       =     np.array(
                 [-0.33_51, 0.22_41, -0.18_37, -0.23_25, -0.65_77, 0.33_93, -0.02_41, 0.58_99, 1.38_75]       )

             assert np.abs(latents_slice.flatten() - expected_slice       ).max() < 1E-3

         _lowercase:			Tuple       =     False

         _lowercase:			Union[str, Any]       =     OnnxStableDiffusionPipeline.from_pretrained(
             '''runwayml/stable-diffusion-v1-5''' ,				revision='''onnx''' ,				safety_checker=A_ ,				feature_extractor=A_ ,				provider=self.gpu_provider ,				sess_options=self.gpu_options ,				)
         pipe.set_progress_bar_config(disable=A_       )

         _lowercase:			List[Any]       =     '''Andromeda galaxy in a bottle'''

         _lowercase:			Any       =     np.random.RandomState(0       )
         pipe(
             prompt=A_ ,				num_inference_steps=5 ,				guidance_scale=7.5 ,				generator=A_ ,				callback=A_ ,				callback_steps=1 ,				)
         assert test_callback_fn.has_been_called
         assert number_of_steps == 6



       def 							lowercase_							(     self       )     ->	int:





         """simple docstring"""




         _lowercase:			Optional[int]       =     OnnxStableDiffusionPipeline.from_pretrained(
             '''runwayml/stable-diffusion-v1-5''' ,				revision='''onnx''' ,				safety_checker=A_ ,				feature_extractor=A_ ,				provider=self.gpu_provider ,				sess_options=self.gpu_options ,				)
         assert isinstance(A_ ,				A_       )
         assert pipe.safety_checker is None

         _lowercase:			Optional[int]       =     pipe('''example prompt''' ,				num_inference_steps=2       ).images[0]
         assert image is not None

         # check that there's no error when saving a pipeline with one of the models being None
         with tempfile.TemporaryDirectory() as tmpdirname:
           pipe.save_pretrained(A_       )
           _lowercase:			str       =     OnnxStableDiffusionPipeline.from_pretrained(A_       )

         # sanity check that the pipeline still works
         assert pipe.safety_checker is None
         _lowercase:			Optional[Any]       =     pipe('''example prompt''' ,				num_inference_steps=2       ).images[0]
         assert image is not None


"""simple docstring"""




import os
import re
import shutil
from argparse import ArgumentParser, Namespace

from datasets.commands import BaseDatasetsCLICommand
from datasets.utils.logging import get_logger


A__   :					Optional[Any]							=   '<<<<<<< This should probably be modified because it mentions: '

A__   :					Any							=   '=======\n>>>>>>>\n'

A__   :					int							=   [
    'TextEncoderConfig',
    'ByteTextEncoder',
    'SubwordTextEncoder',
    'encoder_config',
    'maybe_build_from_corpus',
    'manual_dir',
]

A__   :					Union[str, Any]							=   [
    # (pattern, replacement)
    # Order is important here for some replacements
    (r'tfds\.core', r'datasets'),
    (r'tf\.io\.gfile\.GFile', r'open'),
    (r'tf\.([\w\d]+)', r'datasets.Value(\'\1\')'),
    (r'tfds\.features\.Text\(\)', r'datasets.Value(\'string\')'),
    (r'tfds\.features\.Text\(', r'datasets.Value(\'string\'),'),
    (r'features\s*=\s*tfds.features.FeaturesDict\(', r'features=datasets.Features('),
    (r'tfds\.features\.FeaturesDict\(', r'dict('),
    (r'The TensorFlow Datasets Authors', r'The TensorFlow Datasets Authors and the HuggingFace Datasets Authors'),
    (r'tfds\.', r'datasets.'),
    (r'dl_manager\.manual_dir', r'self.config.data_dir'),
    (r'self\.builder_config', r'self.config'),
]




def  _lowerCAmelCase		(		_UpperCamelCase						):






  """simple docstring"""



  return ConvertCommand(args.tfds_path ,				args.datasets_directory						)







class 			__magic_name__       (       SCREAMING_SNAKE_CASE__ ):
       @staticmethod
       def 							lowercase_							(     A_       )     ->	Union[str, Any]:





         """simple docstring"""




         _lowercase:			int       =     parser.add_parser(
             '''convert''' ,				help='''Convert a TensorFlow Datasets dataset to a HuggingFace Datasets dataset.''' ,				)
         train_parser.add_argument(
             '''--tfds_path''' ,				type=A_ ,				required=A_ ,				help='''Path to a TensorFlow Datasets folder to convert or a single tfds file to convert.''' ,				)
         train_parser.add_argument(
             '''--datasets_directory''' ,				type=A_ ,				required=A_ ,				help='''Path to the HuggingFace Datasets folder.'''       )
         train_parser.set_defaults(func=A_       )
       def __init__(     self ,				A_ ,				A_ ,				*A_       )     ->	Tuple:





         """simple docstring"""




         _lowercase:			Optional[Any]       =     get_logger('''datasets-cli/converting'''       )

         _lowercase:			Optional[Any]       =     tfds_path
         _lowercase:			Dict       =     datasets_directory



       def 							lowercase_							(     self       )     ->	Any:





         """simple docstring"""




         if os.path.isdir(self._tfds_path       ):
           _lowercase:			Optional[Any]       =     os.path.abspath(self._tfds_path       )
         elif os.path.isfile(self._tfds_path       ):
           _lowercase:			Any       =     os.path.dirname(self._tfds_path       )
         else:
           raise ValueError('''--tfds_path is neither a directory nor a file. Please check path.'''       )

         _lowercase:			Dict       =     os.path.abspath(self._datasets_directory       )

         self._logger.info(f'''Converting datasets from {abs_tfds_path} to {abs_datasets_path}'''       )

         _lowercase:			Tuple       =     []
         _lowercase:			List[str]       =     []
         _lowercase:			int       =     {}

         if os.path.isdir(self._tfds_path       ):
           _lowercase:			str       =     os.listdir(A_       )
         else:
           _lowercase:			Tuple       =     [os.path.basename(self._tfds_path       )]

         for f_name in file_names:
           self._logger.info(f'''Looking at file {f_name}'''       )
           _lowercase:			Optional[int]       =     os.path.join(A_ ,				A_       )
           _lowercase:			Optional[Any]       =     os.path.join(A_ ,				A_       )

           if not os.path.isfile(A_       ) or "__init__" in f_name or "_test" in f_name or ".py" not in f_name:
             self._logger.info('''Skipping file'''       )
             continue

           with open(A_ ,				encoding='''utf-8'''       ) as f:
             _lowercase:			Any       =     f.readlines()

           _lowercase:			str       =     []
           _lowercase:			Dict       =     False
           _lowercase:			Any       =     False
           _lowercase:			Tuple       =     []
           for line in lines:
             _lowercase:			str       =     line

             # Convert imports
             if "import tensorflow.compat.v2 as tf" in out_line:
               continue
             elif "@tfds.core" in out_line:
               continue
             elif "builder=self" in out_line:
               continue
             elif "import tensorflow_datasets.public_api as tfds" in out_line:
               _lowercase:			Optional[Any]       =     '''import datasets\n'''
             elif "import tensorflow" in out_line:
               # order is important here
               _lowercase:			Any       =     ''''''
               continue
             elif "from absl import logging" in out_line:
               _lowercase:			Dict       =     '''from datasets import logging\n'''
             elif "getLogger" in out_line:
               _lowercase:			Optional[Any]       =     out_line.replace('''getLogger''' ,				'''get_logger'''       )
             elif any(expression in out_line for expression in TO_HIGHLIGHT       ):
               _lowercase:			int       =     True
               _lowercase:			List[str]       =     list(filter(lambda A_       : e in out_line ,				A_       )       )
               out_lines.append(HIGHLIGHT_MESSAGE_PRE + str(A_       ) + '''\n'''       )
               out_lines.append(A_       )
               out_lines.append(A_       )
               continue
             else:
               for pattern, replacement in TO_CONVERT:
                 _lowercase:			Tuple       =     re.sub(A_ ,				A_ ,				A_       )

                # Take care of saving utilities (to later move them together with main script)
             if "tensorflow_datasets" in out_line:
               _lowercase:			Optional[int]       =     re.match(R'''from\stensorflow_datasets.*import\s([^\.\r\n]+)''' ,				A_       )
               tfds_imports.extend(imp.strip() for imp in match.group(1       ).split(''','''       )       )
               _lowercase:			Dict       =     '''from . import ''' + match.group(1       )

             # Check we have not forget anything
             if "tf." in out_line or "tfds." in out_line or "tensorflow_datasets" in out_line:
               raise ValueError(f'''Error converting {out_line.strip()}'''       )

             if "GeneratorBasedBuilder" in out_line or "BeamBasedBuilder" in out_line:
               _lowercase:			Tuple       =     True
             out_lines.append(A_       )

           if is_builder or "wmt" in f_name:
             # We create a new directory for each dataset
             _lowercase:			List[str]       =     f_name.replace('''.py''' ,				''''''       )
             _lowercase:			Dict       =     os.path.join(A_ ,				A_       )
             _lowercase:			Dict       =     os.path.join(A_ ,				A_       )
             os.makedirs(A_ ,				exist_ok=A_       )
             self._logger.info(f'''Adding directory {output_dir}'''       )
             imports_to_builder_map.update({imp: output_dir for imp in tfds_imports}       )
           else:
             # Utilities will be moved at the end
             utils_files.append(A_       )

           if needs_manual_update:
             with_manual_update.append(A_       )

           with open(A_ ,				'''w''' ,				encoding='''utf-8'''       ) as f:
             f.writelines(A_       )
           self._logger.info(f'''Converted in {output_file}'''       )

         for utils_file in utils_files:
           try:
             _lowercase:			Optional[int]       =     os.path.basename(A_       )
             _lowercase:			List[Any]       =     imports_to_builder_map[f_name.replace('''.py''' ,				''''''       )]
             self._logger.info(f'''Moving {dest_folder} to {utils_file}'''       )
             shutil.copy(A_ ,				A_       )
           except KeyError:
             self._logger.error(f'''Cannot find destination folder for {utils_file}. Please copy manually.'''       )

         if with_manual_update:
           for file_path in with_manual_update:
             self._logger.warning(
                 f'''You need to manually update file {file_path} to remove configurations using \'TextEncoderConfig\'.'''       )
