





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 					UpperCAmelCase_		(			self     ):
									__A	:						Optional[Any]       =				inspect.getfile(accelerate.test_utils     )
									__A	:						Dict       =				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

									__A	:						Dict       =				test_metrics



				@require_cpu
				def 					UpperCAmelCase_		(			self     ):
									debug_launcher(self.test_metrics.main     ,					num_processes=1     )



				@require_cpu
				def 					UpperCAmelCase_		(			self     ):
									debug_launcher(self.test_metrics.main     )



				@require_single_gpu
				def 					UpperCAmelCase_		(			self     ):
									self.test_metrics.main()





				@require_multi_gpu
				def 					UpperCAmelCase_		(			self     ):
									print(F"""Found {torch.cuda.device_count()} devices."""     )
									__A	:						Any       =				['torchrun', F"""--nproc_per_node={torch.cuda.device_count()}""", self.test_file_path]
									with patch_environment(omp_num_threads=1     ):
														execute_subprocess_async(_A     ,					env=os.environ.copy()     )











from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


UpperCAmelCase						:   Any			  =     {
    '''configuration_falcon''': ['''FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FalconConfig'''],
}

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				UpperCAmelCase						:   Any			  =     [
				    '''FALCON_PRETRAINED_MODEL_ARCHIVE_LIST''',
				    '''FalconForCausalLM''',
				    '''FalconModel''',
				    '''FalconPreTrainedModel''',
				    '''FalconForSequenceClassification''',
				    '''FalconForTokenClassification''',
				    '''FalconForQuestionAnswering''',
				]


if TYPE_CHECKING:
				from .configuration_falcon import FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP, FalconConfig

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_falcon import (
								    FALCON_PRETRAINED_MODEL_ARCHIVE_LIST,
								    FalconForCausalLM,
								    FalconForQuestionAnswering,
								    FalconForSequenceClassification,
								    FalconForTokenClassification,
								    FalconModel,
								    FalconPreTrainedModel,
								)


else:
				import sys

				UpperCAmelCase						:   List[str]			  =     _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)




