





# Copyright 2021 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 warnings
from typing import List
from unittest.mock import Mock

import torch
from torch.utils.data import DataLoader, IterableDataset, TensorDataset

from accelerate.accelerator import Accelerator
from accelerate.utils.dataclasses import DistributedType




class 	UpperCamelCase_							(  UpperCamelCase__     ):


							def __init__(				self     :Tuple				,					__A     :Any		) -> Tuple:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   data


							def __iter__(				self     :Union[str, Any]		) -> int:



									"""simple docstring"""



									for element in self.data:
											yield element






def 					SCREAMING_SNAKE_CASE__				(							UpperCamelCase__:				int=True     ):
		SCREAMING_SNAKE_CASE__								=   Accelerator(even_batches=UpperCamelCase__     )
		assert accelerator.num_processes == 2, "this script expects that two GPUs are available"
		return accelerator






def 					SCREAMING_SNAKE_CASE__				(							UpperCamelCase__:				Accelerator       , UpperCamelCase__:				int       , UpperCamelCase__:				int       , UpperCamelCase__:				bool = False     ):
		if iterable:
				SCREAMING_SNAKE_CASE__								=   DummyIterableDataset(torch.as_tensor(range(UpperCamelCase__     )     )     )
		else:
				SCREAMING_SNAKE_CASE__								=   TensorDataset(torch.as_tensor(range(UpperCamelCase__     )     )     )

		SCREAMING_SNAKE_CASE__								=   DataLoader(UpperCamelCase__       , batch_size=UpperCamelCase__     )
		SCREAMING_SNAKE_CASE__								=   accelerator.prepare(UpperCamelCase__     )

		return dl






def 					SCREAMING_SNAKE_CASE__				(							UpperCamelCase__:				Accelerator       , UpperCamelCase__:				int       , UpperCamelCase__:				int       , UpperCamelCase__:				List[int]       , UpperCamelCase__:				List[int]       , ):
		SCREAMING_SNAKE_CASE__								=   create_dataloader(accelerator=UpperCamelCase__       , dataset_size=UpperCamelCase__       , batch_size=UpperCamelCase__     )

		SCREAMING_SNAKE_CASE__								=   [len(batch[0]     ) for batch in dl]

		if accelerator.process_index == 0:
				assert batch_sizes == process_0_expected_batch_sizes
		elif accelerator.process_index == 1:
				assert batch_sizes == process_1_expected_batch_sizes






def 					SCREAMING_SNAKE_CASE__				(							):
		SCREAMING_SNAKE_CASE__								=   create_accelerator()

		# without padding, we would expect a different number of batches
		verify_dataloader_batch_sizes(
		    UpperCamelCase__       , dataset_size=3       , batch_size=1       , process_0_expected_batch_sizes=[1, 1]       , process_1_expected_batch_sizes=[1, 1]       , )

		# without padding, we would expect the same number of batches, but different sizes
		verify_dataloader_batch_sizes(
		    UpperCamelCase__       , dataset_size=7       , batch_size=2       , process_0_expected_batch_sizes=[2, 2]       , process_1_expected_batch_sizes=[2, 2]       , )






def 					SCREAMING_SNAKE_CASE__				(							):
		SCREAMING_SNAKE_CASE__								=   create_accelerator(even_batches=UpperCamelCase__     )

		verify_dataloader_batch_sizes(
		    UpperCamelCase__       , dataset_size=3       , batch_size=1       , process_0_expected_batch_sizes=[1, 1]       , process_1_expected_batch_sizes=[1]       , )

		verify_dataloader_batch_sizes(
		    UpperCamelCase__       , dataset_size=7       , batch_size=2       , process_0_expected_batch_sizes=[2, 2]       , process_1_expected_batch_sizes=[2, 1]       , )






def 					SCREAMING_SNAKE_CASE__				(							):
		SCREAMING_SNAKE_CASE__								=   create_accelerator(even_batches=UpperCamelCase__     )

		SCREAMING_SNAKE_CASE__								=   torch.nn.Linear(1       , 1     )
		SCREAMING_SNAKE_CASE__								=   accelerator.prepare(UpperCamelCase__     )

		SCREAMING_SNAKE_CASE__								=   create_dataloader(UpperCamelCase__       , dataset_size=3       , batch_size=1     )

		SCREAMING_SNAKE_CASE__								=   []
		with accelerator.join_uneven_inputs([ddp_model]     ):
				for batch_idx, batch in enumerate(UpperCamelCase__     ):
						SCREAMING_SNAKE_CASE__								=   ddp_model(batch[0].float()     )
						SCREAMING_SNAKE_CASE__								=   output.sum()
						loss.backward()
						batch_idxs.append(UpperCamelCase__     )

		accelerator.wait_for_everyone()

		if accelerator.process_index == 0:
				assert batch_idxs == [0, 1]
		elif accelerator.process_index == 1:
				assert batch_idxs == [0]






def 					SCREAMING_SNAKE_CASE__				(							UpperCamelCase__:				Optional[Any]     ):
		with warnings.catch_warnings(record=UpperCamelCase__     ) as w:
				with accelerator.join_uneven_inputs([Mock()]     ):
						pass

				assert issubclass(w[-1].category       , UpperCamelCase__     )
				assert "only supported for multi-GPU" in str(w[-1].message     )






def 					SCREAMING_SNAKE_CASE__				(							):
		SCREAMING_SNAKE_CASE__								=   True
		SCREAMING_SNAKE_CASE__								=   False
		SCREAMING_SNAKE_CASE__								=   create_accelerator(even_batches=UpperCamelCase__     )
		SCREAMING_SNAKE_CASE__								=   torch.nn.Linear(1       , 1     )
		SCREAMING_SNAKE_CASE__								=   accelerator.prepare(UpperCamelCase__     )
		SCREAMING_SNAKE_CASE__								=   create_dataloader(UpperCamelCase__       , dataset_size=3       , batch_size=1     )
		SCREAMING_SNAKE_CASE__								=   create_dataloader(UpperCamelCase__       , dataset_size=3       , batch_size=1     )

		with accelerator.join_uneven_inputs([ddp_model]       , even_batches=UpperCamelCase__     ):
				SCREAMING_SNAKE_CASE__								=   train_dl.batch_sampler.even_batches
				SCREAMING_SNAKE_CASE__								=   valid_dl.batch_sampler.even_batches

		assert train_dl_overridden_value == overridden_even_batches
		assert valid_dl_overridden_value == overridden_even_batches
		assert train_dl.batch_sampler.even_batches == default_even_batches
		assert valid_dl.batch_sampler.even_batches == default_even_batches






def 					SCREAMING_SNAKE_CASE__				(							):
		SCREAMING_SNAKE_CASE__								=   True
		SCREAMING_SNAKE_CASE__								=   False
		SCREAMING_SNAKE_CASE__								=   create_accelerator(even_batches=UpperCamelCase__     )
		SCREAMING_SNAKE_CASE__								=   torch.nn.Linear(1       , 1     )
		SCREAMING_SNAKE_CASE__								=   accelerator.prepare(UpperCamelCase__     )
		create_dataloader(UpperCamelCase__       , dataset_size=3       , batch_size=1       , iterable=UpperCamelCase__     )
		SCREAMING_SNAKE_CASE__								=   create_dataloader(UpperCamelCase__       , dataset_size=3       , batch_size=1     )

		with warnings.catch_warnings():
				warnings.filterwarnings("""ignore"""     )
				try:
						with accelerator.join_uneven_inputs([ddp_model]       , even_batches=UpperCamelCase__     ):
								SCREAMING_SNAKE_CASE__								=   batch_dl.batch_sampler.even_batches
				except AttributeError:
						# ensure attribute error is not raised when processing iterable dl
						raise AssertionError

		assert batch_dl_overridden_value == overridden_even_batches
		assert batch_dl.batch_sampler.even_batches == default_even_batches






def 					SCREAMING_SNAKE_CASE__				(							):
		SCREAMING_SNAKE_CASE__								=   create_accelerator()
		SCREAMING_SNAKE_CASE__								=   torch.nn.Linear(1       , 1     )
		SCREAMING_SNAKE_CASE__								=   accelerator.prepare(UpperCamelCase__     )
		create_dataloader(UpperCamelCase__       , dataset_size=3       , batch_size=1       , iterable=UpperCamelCase__     )

		with warnings.catch_warnings(record=UpperCamelCase__     ) as w:
				with accelerator.join_uneven_inputs([ddp_model]       , even_batches=UpperCamelCase__     ):
						pass

				assert issubclass(w[-1].category       , UpperCamelCase__     )
				assert "only supported for map-style datasets" in str(w[-1].message     )






def 					SCREAMING_SNAKE_CASE__				(							):
		SCREAMING_SNAKE_CASE__								=   create_accelerator()

		accelerator.print("""Test that even_batches variable ensures uniform batches across processes"""     )
		test_default_ensures_even_batch_sizes()

		accelerator.print("""Run tests with even_batches disabled"""     )
		test_can_disable_even_batches()

		accelerator.print("""Test joining uneven inputs"""     )
		test_can_join_uneven_inputs()

		accelerator.print("""Test overriding even_batches when joining uneven inputs"""     )
		test_join_can_override_even_batches()

		accelerator.print("""Test overriding even_batches for mixed dataloader types"""     )
		test_join_can_override_for_mixed_type_dataloaders()

		accelerator.print("""Test overriding even_batches raises a warning for iterable dataloaders"""     )
		test_join_raises_warning_for_iterable_when_overriding_even_batches()

		accelerator.print("""Test join with non DDP distributed raises warning"""     )
		SCREAMING_SNAKE_CASE__								=   accelerator.state.distributed_type
		SCREAMING_SNAKE_CASE__								=   DistributedType.FSDP
		test_join_raises_warning_for_non_ddp_distributed(UpperCamelCase__     )
		SCREAMING_SNAKE_CASE__								=   original_state


if __name__ == "__main__":
	main()






import inspect
import os

import torch
from transformers import AutoModel
from transformers.testing_utils import mockenv_context
from transformers.trainer_utils import set_seed

import accelerate
from accelerate.accelerator import Accelerator
from accelerate.state import AcceleratorState
from accelerate.test_utils.testing import (
    AccelerateTestCase,
    TempDirTestCase,
    execute_subprocess_async,
    require_cuda,
    require_fsdp,
    require_multi_gpu,
    slow,
)
from accelerate.utils.constants import (
    FSDP_AUTO_WRAP_POLICY,
    FSDP_BACKWARD_PREFETCH,
    FSDP_SHARDING_STRATEGY,
    FSDP_STATE_DICT_TYPE,
)
from accelerate.utils.dataclasses import FullyShardedDataParallelPlugin
from accelerate.utils.other import patch_environment


set_seed(42)

_lowerCamelCase 					=      'bert-base-cased'
_lowerCamelCase 					=      'fp16'
_lowerCamelCase 					=      'bf16'
_lowerCamelCase 					=      [FPaa, BFaa]




@require_fsdp
@require_cuda
class 	UpperCamelCase_							(  UpperCamelCase__     ):


							def   _snake_case	(				self     :Optional[Any]		) -> Optional[Any]:



									"""simple docstring"""



									super().setUp()

									SCREAMING_SNAKE_CASE__								=   dict(
									    ACCELERATE_USE_FSDP="""true"""				,					MASTER_ADDR="""localhost"""				,					MASTER_PORT="""10999"""				,					RANK="""0"""				,					LOCAL_RANK="""0"""				,					WORLD_SIZE="""1"""				,					)


							def   _snake_case	(				self     :List[Any]		) -> Tuple:



									"""simple docstring"""



									from torch.distributed.fsdp.fully_sharded_data_parallel import ShardingStrategy

									for i, strategy in enumerate(__A		):
											SCREAMING_SNAKE_CASE__								=   self.dist_env.copy()
											SCREAMING_SNAKE_CASE__								=   f'''{i + 1}'''
											SCREAMING_SNAKE_CASE__								=   strategy
											with mockenv_context(**__A		):
													SCREAMING_SNAKE_CASE__								=   FullyShardedDataParallelPlugin()
													self.assertEqual(fsdp_plugin.sharding_strategy				,					ShardingStrategy(i + 1		)		)


							def   _snake_case	(				self     :int		) -> List[str]:



									"""simple docstring"""



									from torch.distributed.fsdp.fully_sharded_data_parallel import BackwardPrefetch

									for i, prefetch_policy in enumerate(__A		):
											SCREAMING_SNAKE_CASE__								=   self.dist_env.copy()
											SCREAMING_SNAKE_CASE__								=   prefetch_policy
											with mockenv_context(**__A		):
													SCREAMING_SNAKE_CASE__								=   FullyShardedDataParallelPlugin()
													if prefetch_policy == "NO_PREFETCH":
															self.assertIsNone(fsdp_plugin.backward_prefetch		)
													else:
															self.assertEqual(fsdp_plugin.backward_prefetch				,					BackwardPrefetch(i + 1		)		)


							def   _snake_case	(				self     :List[str]		) -> List[str]:



									"""simple docstring"""



									from torch.distributed.fsdp.fully_sharded_data_parallel import StateDictType

									for i, state_dict_type in enumerate(__A		):
											SCREAMING_SNAKE_CASE__								=   self.dist_env.copy()
											SCREAMING_SNAKE_CASE__								=   state_dict_type
											with mockenv_context(**__A		):
													SCREAMING_SNAKE_CASE__								=   FullyShardedDataParallelPlugin()
													self.assertEqual(fsdp_plugin.state_dict_type				,					StateDictType(i + 1		)		)
													if state_dict_type == "FULL_STATE_DICT":
															self.assertTrue(fsdp_plugin.state_dict_config.offload_to_cpu		)
															self.assertTrue(fsdp_plugin.state_dict_config.ranka_only		)


							def   _snake_case	(				self     :str		) -> str:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   AutoModel.from_pretrained(__A		)
									for policy in FSDP_AUTO_WRAP_POLICY:
											SCREAMING_SNAKE_CASE__								=   self.dist_env.copy()
											SCREAMING_SNAKE_CASE__								=   policy
											if policy == "TRANSFORMER_BASED_WRAP":
													SCREAMING_SNAKE_CASE__								=   """BertLayer"""
											elif policy == "SIZE_BASED_WRAP":
													SCREAMING_SNAKE_CASE__								=   """2000"""
											with mockenv_context(**__A		):
													SCREAMING_SNAKE_CASE__								=   FullyShardedDataParallelPlugin()
													fsdp_plugin.set_auto_wrap_policy(__A		)
													if policy == "NO_WRAP":
															self.assertIsNone(fsdp_plugin.auto_wrap_policy		)
													else:
															self.assertIsNotNone(fsdp_plugin.auto_wrap_policy		)

									SCREAMING_SNAKE_CASE__								=   self.dist_env.copy()
									SCREAMING_SNAKE_CASE__								=   """TRANSFORMER_BASED_WRAP"""
									SCREAMING_SNAKE_CASE__								=   """T5Layer"""
									with mockenv_context(**__A		):
											SCREAMING_SNAKE_CASE__								=   FullyShardedDataParallelPlugin()
											with self.assertRaises(__A		) as cm:
													fsdp_plugin.set_auto_wrap_policy(__A		)
											self.assertTrue("""Could not find the transformer layer class to wrap in the model.""" in str(cm.exception		)		)

									SCREAMING_SNAKE_CASE__								=   self.dist_env.copy()
									SCREAMING_SNAKE_CASE__								=   """SIZE_BASED_WRAP"""
									SCREAMING_SNAKE_CASE__								=   """0"""
									with mockenv_context(**__A		):
											SCREAMING_SNAKE_CASE__								=   FullyShardedDataParallelPlugin()
											fsdp_plugin.set_auto_wrap_policy(__A		)
											self.assertIsNone(fsdp_plugin.auto_wrap_policy		)


							def   _snake_case	(				self     :Optional[Any]		) -> Optional[int]:



									"""simple docstring"""



									from torch.distributed.fsdp.fully_sharded_data_parallel import MixedPrecision
									from torch.distributed.fsdp.sharded_grad_scaler import ShardedGradScaler

									for mp_dtype in dtypes:
											SCREAMING_SNAKE_CASE__								=   self.dist_env.copy()
											SCREAMING_SNAKE_CASE__								=   mp_dtype
											with mockenv_context(**__A		):
													SCREAMING_SNAKE_CASE__								=   Accelerator()
													if mp_dtype == "fp16":
															SCREAMING_SNAKE_CASE__								=   torch.floataa
													elif mp_dtype == "bf16":
															SCREAMING_SNAKE_CASE__								=   torch.bfloataa
													SCREAMING_SNAKE_CASE__								=   MixedPrecision(param_dtype=__A				,					reduce_dtype=__A				,					buffer_dtype=__A		)
													self.assertEqual(accelerator.state.fsdp_plugin.mixed_precision_policy				,					__A		)
													if mp_dtype == FPaa:
															self.assertTrue(isinstance(accelerator.scaler				,					__A		)		)
													elif mp_dtype == BFaa:
															self.assertIsNone(accelerator.scaler		)
													AcceleratorState._reset_state(__A		)


							def   _snake_case	(				self     :str		) -> str:



									"""simple docstring"""



									from torch.distributed.fsdp.fully_sharded_data_parallel import CPUOffload

									for flag in [True, False]:
											SCREAMING_SNAKE_CASE__								=   self.dist_env.copy()
											SCREAMING_SNAKE_CASE__								=   str(__A		).lower()
											with mockenv_context(**__A		):
													SCREAMING_SNAKE_CASE__								=   FullyShardedDataParallelPlugin()
													self.assertEqual(fsdp_plugin.cpu_offload				,					CPUOffload(offload_params=__A		)		)




@require_fsdp
@require_multi_gpu
@slow
class 	UpperCamelCase_							(  UpperCamelCase__     ):


							def   _snake_case	(				self     :Any		) -> Any:



									"""simple docstring"""



									super().setUp()
									SCREAMING_SNAKE_CASE__								=   0.8_2
									SCREAMING_SNAKE_CASE__								=   [
									    """fsdp_shard_grad_op_transformer_based_wrap""",
									    """fsdp_full_shard_transformer_based_wrap""",
									]
									SCREAMING_SNAKE_CASE__								=   {
									    """multi_gpu_fp16""": 3200,
									    """fsdp_shard_grad_op_transformer_based_wrap_fp16""": 2000,
									    """fsdp_full_shard_transformer_based_wrap_fp16""": 1900,
									    # Disabling below test as it overwhelms the RAM memory usage
									    # on CI self-hosted runner leading to tests getting killed.
									    # "fsdp_full_shard_cpu_offload_transformer_based_wrap_fp32": 1500,  # fp16 was leading to indefinite hang
									}
									SCREAMING_SNAKE_CASE__								=   160
									SCREAMING_SNAKE_CASE__								=   160

									SCREAMING_SNAKE_CASE__								=   inspect.getfile(accelerate.test_utils		)
									SCREAMING_SNAKE_CASE__								=   os.path.sep.join(mod_file.split(os.path.sep		)[:-1] + ["""scripts""", """external_deps"""]		)


							def   _snake_case	(				self     :Union[str, Any]		) -> int:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   os.path.join(self.test_scripts_folder				,					"""test_performance.py"""		)
									SCREAMING_SNAKE_CASE__								=   ["""accelerate""", """launch""", """--num_processes=2""", """--num_machines=1""", """--machine_rank=0""", """--use_fsdp"""]
									for config in self.performance_configs:
											SCREAMING_SNAKE_CASE__								=   cmd.copy()
											for i, strategy in enumerate(__A		):
													if strategy.lower() in config:
															cmd_config.append(f'''--fsdp_sharding_strategy={i+1}'''		)
															break

											if "fp32" in config:
													cmd_config.append("""--mixed_precision=no"""		)
											else:
													cmd_config.append("""--mixed_precision=fp16"""		)

											if "cpu_offload" in config:
													cmd_config.append("""--fsdp_offload_params=True"""		)

											for policy in FSDP_AUTO_WRAP_POLICY:
													if policy.lower() in config:
															cmd_config.append(f'''--fsdp_auto_wrap_policy={policy}'''		)
															break

											if policy == "TRANSFORMER_BASED_WRAP":
													cmd_config.append("""--fsdp_transformer_layer_cls_to_wrap=BertLayer"""		)
											elif policy == "SIZE_BASED_WRAP":
													cmd_config.append("""--fsdp_min_num_params=2000"""		)

											cmd_config.extend(
											    [
											        self.test_file_path,
											        f'''--output_dir={self.tmpdir}''',
											        f'''--performance_lower_bound={self.performance_lower_bound}''',
											    ]		)
											with patch_environment(omp_num_threads=1		):
													execute_subprocess_async(__A				,					env=os.environ.copy()		)


							def   _snake_case	(				self     :Dict		) -> Union[str, Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   os.path.join(self.test_scripts_folder				,					"""test_checkpointing.py"""		)
									SCREAMING_SNAKE_CASE__								=   [
									    """accelerate""",
									    """launch""",
									    """--num_processes=2""",
									    """--num_machines=1""",
									    """--machine_rank=0""",
									    """--use_fsdp""",
									    """--mixed_precision=fp16""",
									    """--fsdp_transformer_layer_cls_to_wrap=BertLayer""",
									]

									for i, strategy in enumerate(__A		):
											SCREAMING_SNAKE_CASE__								=   cmd.copy()
											cmd_config.append(f'''--fsdp_sharding_strategy={i+1}'''		)
											if strategy != "FULL_SHARD":
													continue
											SCREAMING_SNAKE_CASE__								=   len(__A		)
											for state_dict_type in FSDP_STATE_DICT_TYPE:
													SCREAMING_SNAKE_CASE__								=   cmd_config[:state_dict_config_index]
													cmd_config.append(f'''--fsdp_state_dict_type={state_dict_type}'''		)
													cmd_config.extend(
													    [
													        self.test_file_path,
													        f'''--output_dir={self.tmpdir}''',
													        """--partial_train_epoch=1""",
													    ]		)
													with patch_environment(omp_num_threads=1		):
															execute_subprocess_async(__A				,					env=os.environ.copy()		)

													SCREAMING_SNAKE_CASE__								=   cmd_config[:-1]
													SCREAMING_SNAKE_CASE__								=   os.path.join(self.tmpdir				,					"""epoch_0"""		)
													cmd_config.extend(
													    [
													        f'''--resume_from_checkpoint={resume_from_checkpoint}''',
													    ]		)
													with patch_environment(omp_num_threads=1		):
															execute_subprocess_async(__A				,					env=os.environ.copy()		)


							def   _snake_case	(				self     :Tuple		) -> str:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=   os.path.join(self.test_scripts_folder				,					"""test_peak_memory_usage.py"""		)
									SCREAMING_SNAKE_CASE__								=   [
									    """accelerate""",
									    """launch""",
									    """--num_processes=2""",
									    """--num_machines=1""",
									    """--machine_rank=0""",
									]
									for spec, peak_mem_upper_bound in self.peak_memory_usage_upper_bound.items():
											SCREAMING_SNAKE_CASE__								=   cmd.copy()
											if "fp16" in spec:
													cmd_config.extend(["""--mixed_precision=fp16"""]		)
											else:
													cmd_config.extend(["""--mixed_precision=no"""]		)

											if "multi_gpu" in spec:
													continue
											else:
													cmd_config.extend(["""--use_fsdp"""]		)
													for i, strategy in enumerate(__A		):
															if strategy.lower() in spec:
																	cmd_config.append(f'''--fsdp_sharding_strategy={i+1}'''		)
																	break

													if "cpu_offload" in spec:
															cmd_config.append("""--fsdp_offload_params=True"""		)

													for policy in FSDP_AUTO_WRAP_POLICY:
															if policy.lower() in spec:
																	cmd_config.append(f'''--fsdp_auto_wrap_policy={policy}'''		)
																	break

													if policy == "TRANSFORMER_BASED_WRAP":
															cmd_config.append("""--fsdp_transformer_layer_cls_to_wrap=BertLayer"""		)
													elif policy == "SIZE_BASED_WRAP":
															cmd_config.append("""--fsdp_min_num_params=2000"""		)

											cmd_config.extend(
											    [
											        self.test_file_path,
											        f'''--output_dir={self.tmpdir}''',
											        f'''--peak_memory_upper_bound={peak_mem_upper_bound}''',
											        f'''--n_train={self.n_train}''',
											        f'''--n_val={self.n_val}''',
											    ]		)
											with patch_environment(omp_num_threads=1		):
													execute_subprocess_async(__A				,					env=os.environ.copy()		)