


"""simple docstring"""


from typing import Callable, Optional

from .. import Features
from ..packaged_modules.generator.generator import Generator
from .abc import AbstractDatasetInputStream



class 			lowerCamelCase__						(   UpperCAmelCase_			):







						def __init__(							self   :    List[str]			,			_lowercase   :    Callable			,			_lowercase   :    Optional[Features] = None			,			_lowercase   :    str = None			,			_lowercase   :    bool = False			,			_lowercase   :    bool = False			,			_lowercase   :    Optional[dict] = None			,			_lowercase   :    Optional[int] = None			,			**_lowercase   :    List[Any]			,			):
								super().__init__(
								    features=_lowercase			,			cache_dir=_lowercase			,			keep_in_memory=_lowercase			,			streaming=_lowercase			,			num_proc=_lowercase			,			**_lowercase			,			)
								A					       = Generator(
								    cache_dir=_lowercase			,			features=_lowercase			,			generator=_lowercase			,			gen_kwargs=_lowercase			,			**_lowercase			,			)







						def __a						(							self   :    int		):
								# Build iterable dataset
								if self.streaming:
										A					       = self.builder.as_streaming_dataset(split='train'		)
								# Build regular (map-style) dataset
								else:
										A					       = None
										A					       = None
										A					       = None
										A					       = None

										self.builder.download_and_prepare(
										    download_config=_lowercase			,			download_mode=_lowercase			,			verification_mode=_lowercase			,			base_path=_lowercase			,			num_proc=self.num_proc			,			)
										A					       = self.builder.as_dataset(
										    split='train'			,			verification_mode=_lowercase			,			in_memory=self.keep_in_memory		)
								return dataset









"""simple docstring"""


import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible



class 			lowerCamelCase__						(   unittest.TestCase			):







						def __a						(							self   :    Dict		):
								A					       = [
								    'safety_checker/pytorch_model.bin',
								    'safety_checker/model.safetensors',
								    'vae/diffusion_pytorch_model.bin',
								    'vae/diffusion_pytorch_model.safetensors',
								    'text_encoder/pytorch_model.bin',
								    'text_encoder/model.safetensors',
								    'unet/diffusion_pytorch_model.bin',
								    'unet/diffusion_pytorch_model.safetensors',
								]
								self.assertTrue(is_safetensors_compatible(_lowercase		)		)







						def __a						(							self   :    Union[str, Any]		):
								A					       = [
								    'unet/diffusion_pytorch_model.bin',
								    'unet/diffusion_pytorch_model.safetensors',
								]
								self.assertTrue(is_safetensors_compatible(_lowercase		)		)







						def __a						(							self   :    int		):
								A					       = [
								    'safety_checker/pytorch_model.bin',
								    'safety_checker/model.safetensors',
								    'vae/diffusion_pytorch_model.bin',
								    'vae/diffusion_pytorch_model.safetensors',
								    'text_encoder/pytorch_model.bin',
								    'text_encoder/model.safetensors',
								    'unet/diffusion_pytorch_model.bin',
								    # Removed: 'unet/diffusion_pytorch_model.safetensors',
								]
								self.assertFalse(is_safetensors_compatible(_lowercase		)		)







						def __a						(							self   :    Dict		):
								A					       = [
								    'text_encoder/pytorch_model.bin',
								    'text_encoder/model.safetensors',
								]
								self.assertTrue(is_safetensors_compatible(_lowercase		)		)







						def __a						(							self   :    Union[str, Any]		):
								A					       = [
								    'safety_checker/pytorch_model.bin',
								    'safety_checker/model.safetensors',
								    'vae/diffusion_pytorch_model.bin',
								    'vae/diffusion_pytorch_model.safetensors',
								    'text_encoder/pytorch_model.bin',
								    # Removed: 'text_encoder/model.safetensors',
								    'unet/diffusion_pytorch_model.bin',
								    'unet/diffusion_pytorch_model.safetensors',
								]
								self.assertFalse(is_safetensors_compatible(_lowercase		)		)







						def __a						(							self   :    Any		):
								A					       = [
								    'safety_checker/pytorch_model.fp16.bin',
								    'safety_checker/model.fp16.safetensors',
								    'vae/diffusion_pytorch_model.fp16.bin',
								    'vae/diffusion_pytorch_model.fp16.safetensors',
								    'text_encoder/pytorch_model.fp16.bin',
								    'text_encoder/model.fp16.safetensors',
								    'unet/diffusion_pytorch_model.fp16.bin',
								    'unet/diffusion_pytorch_model.fp16.safetensors',
								]
								A					       = 'fp16'
								self.assertTrue(is_safetensors_compatible(_lowercase			,			variant=_lowercase		)		)







						def __a						(							self   :    Union[str, Any]		):
								A					       = [
								    'unet/diffusion_pytorch_model.fp16.bin',
								    'unet/diffusion_pytorch_model.fp16.safetensors',
								]
								A					       = 'fp16'
								self.assertTrue(is_safetensors_compatible(_lowercase			,			variant=_lowercase		)		)







						def __a						(							self   :    Optional[Any]		):
								# pass variant but use the non-variant filenames
								A					       = [
								    'unet/diffusion_pytorch_model.bin',
								    'unet/diffusion_pytorch_model.safetensors',
								]
								A					       = 'fp16'
								self.assertTrue(is_safetensors_compatible(_lowercase			,			variant=_lowercase		)		)







						def __a						(							self   :    Dict		):
								A					       = [
								    'safety_checker/pytorch_model.fp16.bin',
								    'safety_checker/model.fp16.safetensors',
								    'vae/diffusion_pytorch_model.fp16.bin',
								    'vae/diffusion_pytorch_model.fp16.safetensors',
								    'text_encoder/pytorch_model.fp16.bin',
								    'text_encoder/model.fp16.safetensors',
								    'unet/diffusion_pytorch_model.fp16.bin',
								    # Removed: 'unet/diffusion_pytorch_model.fp16.safetensors',
								]
								A					       = 'fp16'
								self.assertFalse(is_safetensors_compatible(_lowercase			,			variant=_lowercase		)		)







						def __a						(							self   :    Dict		):
								A					       = [
								    'text_encoder/pytorch_model.fp16.bin',
								    'text_encoder/model.fp16.safetensors',
								]
								A					       = 'fp16'
								self.assertTrue(is_safetensors_compatible(_lowercase			,			variant=_lowercase		)		)







						def __a						(							self   :    Any		):
								# pass variant but use the non-variant filenames
								A					       = [
								    'text_encoder/pytorch_model.bin',
								    'text_encoder/model.safetensors',
								]
								A					       = 'fp16'
								self.assertTrue(is_safetensors_compatible(_lowercase			,			variant=_lowercase		)		)







						def __a						(							self   :    List[str]		):
								A					       = [
								    'safety_checker/pytorch_model.fp16.bin',
								    'safety_checker/model.fp16.safetensors',
								    'vae/diffusion_pytorch_model.fp16.bin',
								    'vae/diffusion_pytorch_model.fp16.safetensors',
								    'text_encoder/pytorch_model.fp16.bin',
								    # 'text_encoder/model.fp16.safetensors',
								    'unet/diffusion_pytorch_model.fp16.bin',
								    'unet/diffusion_pytorch_model.fp16.safetensors',
								]
								A					       = 'fp16'
								self.assertFalse(is_safetensors_compatible(_lowercase			,			variant=_lowercase		)		)





