





from dataclasses import dataclass
from enum import Enum
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
class        _UpperCamelCase				(						_UpperCAmelCase			):


			"""simple docstring"""






			__a  :			str      			=						{
			    '''sld_warmup_steps''': 15,
			    '''sld_guidance_scale''': 20,
			    '''sld_threshold''': 0.0,
			    '''sld_momentum_scale''': 0.0,
			    '''sld_mom_beta''': 0.0,
			}
			__a  :			int      			=						{
			    '''sld_warmup_steps''': 10,
			    '''sld_guidance_scale''': 1000,
			    '''sld_threshold''': 0.01,
			    '''sld_momentum_scale''': 0.3,
			    '''sld_mom_beta''': 0.4,
			}
			__a  :			List[Any]      			=						{
			    '''sld_warmup_steps''': 7,
			    '''sld_guidance_scale''': 2000,
			    '''sld_threshold''': 0.025,
			    '''sld_momentum_scale''': 0.5,
			    '''sld_mom_beta''': 0.7,
			}
			__a  :			Dict      			=						{
			    '''sld_warmup_steps''': 0,
			    '''sld_guidance_scale''': 5000,
			    '''sld_threshold''': 1.0,
			    '''sld_momentum_scale''': 0.5,
			    '''sld_mom_beta''': 0.7,
			}




@dataclass
class        _UpperCamelCase				(						_UpperCAmelCase			):


			"""simple docstring"""






			__a  :			Union[List[PIL.Image.Image], np.ndarray]
			__a  :			Optional[List[bool]]
			__a  :			Optional[Union[List[PIL.Image.Image], np.ndarray]]
			__a  :			Optional[str]


if is_transformers_available() and is_torch_available():
		from .pipeline_stable_diffusion_safe import StableDiffusionPipelineSafe
		from .safety_checker import SafeStableDiffusionSafetyChecker
import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


__a  :					int          =  5_0_0_0_0_0

__a   ,						__a  :					Any          =  os.path.split(__file__)
__a  :					Dict          =  os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace(""".py""", """.json"""))





@get_duration
def     UpperCAmelCase						(   lowercase							):







				"""simple docstring"""



				__lowercase			      =							dataset.select(range(0							,      len(lowercase							)							,      2							)							)





@get_duration
def     UpperCAmelCase						(   lowercase							):







				"""simple docstring"""



				__lowercase			      =							dataset.sort('''numbers'''							)





@get_duration
def     UpperCAmelCase						(   lowercase							):







				"""simple docstring"""



				__lowercase			      =							dataset.shuffle()





@get_duration
def     UpperCAmelCase						(   lowercase							):







				"""simple docstring"""



				__lowercase			      =							dataset.train_test_split(0.1							)





@get_duration
def     UpperCAmelCase						(   lowercase							,      lowercase=10							):







				"""simple docstring"""



				for shard_id in range(lowercase							):
								__lowercase			      =							dataset.shard(lowercase							,      lowercase							)





def     UpperCAmelCase						(   ):







				"""simple docstring"""



				__lowercase			      =							{'''num examples''': SPEED_TEST_N_EXAMPLES}
				__lowercase			      =							(select, sort, shuffle, train_test_split, shard)
				with tempfile.TemporaryDirectory() as tmp_dir:
								print('''generating dataset'''							)
								__lowercase			      =							datasets.Features({'''text''': datasets.Value('''string'''							), '''numbers''': datasets.Value('''float32'''							)}							)
								__lowercase			      =							generate_example_dataset(
								    os.path.join(lowercase							,      '''dataset.arrow'''							)							,      lowercase							,      num_examples=lowercase							)
								print('''Functions'''							)
								for func in functions:
												print(func.__name__							)
												__lowercase			      =							func(lowercase							)

				with open(lowercase							,      '''wb'''							) as f:
								f.write(json.dumps(lowercase							).encode('''utf-8'''							)							)


if __name__ == "__main__":  # useful to run the profiler
		benchmark_indices_mapping()