



"""simple docstring"""


import pytest

import datasets.config
from datasets.utils.info_utils import is_small_dataset







@pytest.mark.parametrize('''dataset_size'''					,     [None, 400 * 2**20, 600 * 2**20]				)
@pytest.mark.parametrize('''input_in_memory_max_size'''					,     ['''default''', 0, 100 * 2**20, 900 * 2**20]				)
def  _a	(      _SCREAMING_SNAKE_CASE   :						Optional[int]					,     _SCREAMING_SNAKE_CASE   :						Optional[Any]					,     _SCREAMING_SNAKE_CASE   :						List[Any]				):






				'''simple docstring'''



				if input_in_memory_max_size != "default":
								monkeypatch.setattr(datasets.config					,     '''IN_MEMORY_MAX_SIZE'''					,     snake_case__				)
				_UpperCAmelCase					=    datasets.config.IN_MEMORY_MAX_SIZE
				if input_in_memory_max_size == "default":
								assert in_memory_max_size == 0
				else:
								assert in_memory_max_size == input_in_memory_max_size
				if dataset_size and in_memory_max_size:
								_UpperCAmelCase					=    dataset_size < in_memory_max_size
				else:
								_UpperCAmelCase					=    False
				_UpperCAmelCase					=    is_small_dataset(snake_case__				)
				assert result == expected








"""simple docstring"""


import inspect
import os
import unittest

import torch

import accelerate
from accelerate import debug_launcher
from accelerate.test_utils import (
    execute_subprocess_async,
    require_cpu,
    require_huggingface_suite,
    require_multi_gpu,
    require_single_gpu,
)
from accelerate.utils import patch_environment
@require_huggingface_suite
class 			_a (					unittest.TestCase):
			"""simple docstring"""



			def  lowercase__						(		self     :    Tuple   )->int:
							_UpperCAmelCase					=    inspect.getfile(accelerate.test_utils   )
							_UpperCAmelCase					=    os.path.sep.join(
							    mod_file.split(os.path.sep   )[:-1] + ['''scripts''', '''external_deps''', '''test_metrics.py''']   )

							from accelerate.test_utils.scripts.external_deps import test_metrics  # noqa: F401

							_UpperCAmelCase					=    test_metrics



			@require_cpu
			def  lowercase__						(		self     :    Any   )->int:
							debug_launcher(self.test_metrics.main				,   num_processes=1   )



			@require_cpu
			def  lowercase__						(		self     :    List[str]   )->List[str]:
							debug_launcher(self.test_metrics.main   )



			@require_single_gpu
			def  lowercase__						(		self     :    List[Any]   )->Dict:
							self.test_metrics.main()



			@require_multi_gpu
			def  lowercase__						(		self     :    str   )->int:
							print(F'Found {torch.cuda.device_count()} devices.'   )
							_UpperCAmelCase					=    ['''torchrun''', F'--nproc_per_node={torch.cuda.device_count()}', self.test_file_path]
							with patch_environment(omp_num_threads=1   ):
											execute_subprocess_async(__UpperCamelCase				,   env=os.environ.copy()   )



