





from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import PIL
from PIL import Image

from ...utils import BaseOutput, is_torch_available, is_transformers_available

@dataclass
# Copied from diffusers.pipelines.stable_diffusion.__init__.StableDiffusionPipelineOutput with Stable->Alt
class   __snake_case				(			_a   ):






				'''simple docstring'''
				_lowerCAmelCase     =	42
				_lowerCAmelCase     =	42


if is_transformers_available() and is_torch_available():
						from .modeling_roberta_series import RobertaSeriesModelWithTransformation
						from .pipeline_alt_diffusion import AltDiffusionPipeline
						from .pipeline_alt_diffusion_imgaimg import AltDiffusionImgaImgPipeline







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_multi_gpu,
    require_single_gpu,
    test_sync,
)
from accelerate.utils import patch_environment

class   __snake_case				(			unittest.TestCase   ):






    '''simple docstring'''





    def 	A		(   self						:		int							):

      """simple docstring"""





      __lowerCAmelCase			=				inspect.getfile(accelerate.test_utils							)
      __lowerCAmelCase			=				os.path.sep.join(mod_file.split(os.path.sep							)[:-1] + ['''scripts''', '''test_sync.py''']							)





    @require_cpu
    def 	A		(   self						:		str							):

      """simple docstring"""





      debug_launcher(test_sync.main			,						num_processes=1							)





    @require_cpu
    def 	A		(   self						:		List[str]							):

      """simple docstring"""





      debug_launcher(test_sync.main							)





    @require_single_gpu
    def 	A		(   self						:		Optional[Any]							):

      """simple docstring"""





      test_sync.main()





    @require_multi_gpu
    def 	A		(   self						:		Union[str, Any]							):

      """simple docstring"""





      print(f'''Found {torch.cuda.device_count()} devices.'''							)
      __lowerCAmelCase			=				['''torchrun''', f'''--nproc_per_node={torch.cuda.device_count()}''', self.test_file_path]
      with patch_environment(omp_num_threads=1							):
        execute_subprocess_async(snake_case			,						env=os.environ.copy()							)
