
"""simple docstring"""


from ...utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_torch_available,
    is_transformers_available,
)


try:
      if not (is_transformers_available() and is_torch_available()):
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
      from .multicontrolnet import MultiControlNetModel
      from .pipeline_controlnet import StableDiffusionControlNetPipeline
      from .pipeline_controlnet_imgaimg import StableDiffusionControlNetImgaImgPipeline
      from .pipeline_controlnet_inpaint import StableDiffusionControlNetInpaintPipeline


if is_transformers_available() and is_flax_available():
      from .pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline







"""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	):






       def 	_SCREAMING_SNAKE_CASE       (  self :							Optional[int]			)->  Dict:







              """simple docstring"""
              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 	_SCREAMING_SNAKE_CASE       (  self :							Dict			)->  Union[str, Any]:







              """simple docstring"""
              debug_launcher(self.test_metrics.main       ,      num_processes=1			)






       @require_cpu
       def 	_SCREAMING_SNAKE_CASE       (  self :							Tuple			)->  List[str]:







              """simple docstring"""
              debug_launcher(self.test_metrics.main			)






       @require_single_gpu
       def 	_SCREAMING_SNAKE_CASE       (  self :							List[Any]			)->  str:







              """simple docstring"""
              self.test_metrics.main()






       @require_multi_gpu
       def 	_SCREAMING_SNAKE_CASE       (  self :							Optional[Any]			)->  Optional[Any]:







              """simple docstring"""
              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()			)





