"""simple docstring"""



import unittest

import numpy as np
import torch

from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device

from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONAL_IMAGE_GENERATION_PARAMS
from ..test_pipelines_common import PipelineTesterMixin


enable_full_determinism()



class      _A	(						UpperCamelCase_							, unittest.TestCase					):




    """simple docstring"""




    UpperCamelCase_	:					Dict							=					DDIMPipeline
    UpperCamelCase_	:					List[Any]							=					UNCONDITIONAL_IMAGE_GENERATION_PARAMS
    UpperCamelCase_	:					str							=					PipelineTesterMixin.required_optional_params - {
        '''num_images_per_prompt''',
        '''latents''',
        '''callback''',
        '''callback_steps''',
    }
    UpperCamelCase_	:					Union[str, Any]							=					UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS
    UpperCamelCase_	:					Dict							=					False
    def  lowercase					(		self							:     Union[str, Any]    )    ->       Dict:
         torch.manual_seed(0    )
         __snake_case				=							UNetaDModel(
             block_out_channels=(32, 64)	,      layers_per_block=2	,      sample_size=32	,      in_channels=3	,      out_channels=3	,      down_block_types=('''DownBlock2D''', '''AttnDownBlock2D''')	,      up_block_types=('''AttnUpBlock2D''', '''UpBlock2D''')	,      )
         __snake_case				=							DDIMScheduler()
         __snake_case				=							{"unet": unet, "scheduler": scheduler}
         return components
    def  lowercase					(		self							:     Optional[int]	,      A_							:     Any	,      A_							:     Optional[int]=0    )    ->       Any:
         if str(__A    ).startswith('''mps'''    ):
              __snake_case				=							torch.manual_seed(__A    )
         else:
              __snake_case				=							torch.Generator(device=__A    ).manual_seed(__A    )
         __snake_case				=							{
             "batch_size": 1,
             "generator": generator,
             "num_inference_steps": 2,
             "output_type": "numpy",
         }
         return inputs
    def  lowercase					(		self							:     Dict    )    ->       List[Any]:
         __snake_case				=							"cpu"

         __snake_case				=							self.get_dummy_components()
         __snake_case				=							self.pipeline_class(**__A    )
         pipe.to(__A    )
         pipe.set_progress_bar_config(disable=__A    )

         __snake_case				=							self.get_dummy_inputs(__A    )
         __snake_case				=							pipe(**__A    ).images
         __snake_case				=							image[0, -3:, -3:, -1]

         self.assertEqual(image.shape	,      (1, 32, 32, 3)    )
         __snake_case				=							np.array(
             [1.0_0_0E0_0, 5.7_1_7E-0_1, 4.7_1_7E-0_1, 1.0_0_0E0_0, 0.0_0_0E0_0, 1.0_0_0E0_0, 3.0_0_0E-0_4, 0.0_0_0E0_0, 9.0_0_0E-0_4]    )
         __snake_case				=							np.abs(image_slice.flatten() - expected_slice    ).max()
         self.assertLessEqual(__A	,      1E-3    )
    def  lowercase					(		self							:     List[str]    )    ->       Tuple:
         super().test_dict_tuple_outputs_equivalent(expected_max_difference=3E-3    )
    def  lowercase					(		self							:     Union[str, Any]    )    ->       Optional[int]:
         super().test_save_load_local(expected_max_difference=3E-3    )
    def  lowercase					(		self							:     int    )    ->       Optional[int]:
         super().test_save_load_optional_components(expected_max_difference=3E-3    )







    def  lowercase					(		self							:     Dict    )    ->       int:
         super().test_inference_batch_single_identical(expected_max_diff=3E-3    )






@slow
@require_torch_gpu
class      _A	(						unittest.TestCase					):




    """simple docstring"""




    def  lowercase					(		self							:     int    )    ->       int:
         __snake_case				=							"google/ddpm-cifar10-32"

         __snake_case				=							UNetaDModel.from_pretrained(__A    )
         __snake_case				=							DDIMScheduler()

         __snake_case				=							DDIMPipeline(unet=__A	,      scheduler=__A    )
         ddim.to(__A    )
         ddim.set_progress_bar_config(disable=__A    )

         __snake_case				=							torch.manual_seed(0    )
         __snake_case				=							ddim(generator=__A	,      eta=0.0	,      output_type='''numpy'''    ).images

         __snake_case				=							image[0, -3:, -3:, -1]

         assert image.shape == (1, 32, 32, 3)
         __snake_case				=							np.array([0.17_23, 0.16_17, 0.16_00, 0.16_26, 0.14_97, 0.15_13, 0.15_05, 0.14_42, 0.14_53]    )

         assert np.abs(image_slice.flatten() - expected_slice    ).max() < 1E-2







    def  lowercase					(		self							:     List[str]    )    ->       Any:
         __snake_case				=							"google/ddpm-ema-bedroom-256"

         __snake_case				=							UNetaDModel.from_pretrained(__A    )
         __snake_case				=							DDIMScheduler.from_pretrained(__A    )

         __snake_case				=							DDIMPipeline(unet=__A	,      scheduler=__A    )
         ddpm.to(__A    )
         ddpm.set_progress_bar_config(disable=__A    )

         __snake_case				=							torch.manual_seed(0    )
         __snake_case				=							ddpm(generator=__A	,      output_type='''numpy'''    ).images

         __snake_case				=							image[0, -3:, -3:, -1]

         assert image.shape == (1, 256, 256, 3)
         __snake_case				=							np.array([0.00_60, 0.02_01, 0.03_44, 0.00_24, 0.00_18, 0.00_02, 0.00_22, 0.00_00, 0.00_69]    )

         assert np.abs(image_slice.flatten() - expected_slice    ).max() < 1E-2
"""simple docstring"""



import re





def    SCREAMING_SNAKE_CASE       (     snake_case):
     __snake_case				=							re.compile(R'''^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$''')
     if match := re.search(snake_case,      snake_case):
          return match.string == phone
     return False


if __name__ == "__main__":
       print(indian_phone_validator("+918827897895"))