


import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible


class 		_SCREAMING_SNAKE_CASE     (						unittest.TestCase     ):


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Optional[int]							=     [
           """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(A_    )    )


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							str							=     [
           """unet/diffusion_pytorch_model.bin""",
           """unet/diffusion_pytorch_model.safetensors""",
       ]
       self.assertTrue(is_safetensors_compatible(A_    )    )


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Optional[int]							=     [
           """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(A_    )    )


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Dict							=     [
           """text_encoder/pytorch_model.bin""",
           """text_encoder/model.safetensors""",
       ]
       self.assertTrue(is_safetensors_compatible(A_    )    )


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Optional[Any]							=     [
           """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(A_    )    )


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							List[str]							=     [
           """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""",
       ]
       _UpperCAmelCase		:							Union[str, Any]							=     """fp16"""
       self.assertTrue(is_safetensors_compatible(A_							,					variant=A_    )    )


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Dict							=     [
           """unet/diffusion_pytorch_model.fp16.bin""",
           """unet/diffusion_pytorch_model.fp16.safetensors""",
       ]
       _UpperCAmelCase		:							int							=     """fp16"""
       self.assertTrue(is_safetensors_compatible(A_							,					variant=A_    )    )


     def        __snake_case(  self    ):
       # pass variant but use the non-variant filenames
       _UpperCAmelCase		:							int							=     [
           """unet/diffusion_pytorch_model.bin""",
           """unet/diffusion_pytorch_model.safetensors""",
       ]
       _UpperCAmelCase		:							int							=     """fp16"""
       self.assertTrue(is_safetensors_compatible(A_							,					variant=A_    )    )


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							int							=     [
           """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',
       ]
       _UpperCAmelCase		:							int							=     """fp16"""
       self.assertFalse(is_safetensors_compatible(A_							,					variant=A_    )    )


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Optional[int]							=     [
           """text_encoder/pytorch_model.fp16.bin""",
           """text_encoder/model.fp16.safetensors""",
       ]
       _UpperCAmelCase		:							Any							=     """fp16"""
       self.assertTrue(is_safetensors_compatible(A_							,					variant=A_    )    )


     def        __snake_case(  self    ):
       # pass variant but use the non-variant filenames
       _UpperCAmelCase		:							Union[str, Any]							=     [
           """text_encoder/pytorch_model.bin""",
           """text_encoder/model.safetensors""",
       ]
       _UpperCAmelCase		:							Tuple							=     """fp16"""
       self.assertTrue(is_safetensors_compatible(A_							,					variant=A_    )    )




     def        __snake_case(  self    ):
       _UpperCAmelCase		:							List[str]							=     [
           """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""",
       ]
       _UpperCAmelCase		:							List[Any]							=     """fp16"""
       self.assertFalse(is_safetensors_compatible(A_							,					variant=A_    )    )









import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import ClassLabel, Features, Image
from .base import TaskTemplate


@dataclass(frozen=A     )
class 		_SCREAMING_SNAKE_CASE     (						A     ):
     __SCREAMING_SNAKE_CASE     					=    field(default='''image-classification'''							,	metadata={'''include_in_asdict_even_if_is_default''': True}     )
     __SCREAMING_SNAKE_CASE     					=    Features({'''image''': Image()}     )
     __SCREAMING_SNAKE_CASE     					=    Features({'''labels''': ClassLabel}     )
     __SCREAMING_SNAKE_CASE     					=    "image"
     __SCREAMING_SNAKE_CASE     					=    "labels"


     def        __snake_case(  self							,					A_    ):
       if self.label_column not in features:
         raise ValueError(F'''Column {self.label_column} is not present in features.'''    )
       if not isinstance(features[self.label_column]							,					A_    ):
         raise ValueError(F'''Column {self.label_column} is not a ClassLabel.'''    )
       _UpperCAmelCase		:							Tuple							=     copy.deepcopy(self    )
       _UpperCAmelCase		:							str							=     self.label_schema.copy()
       _UpperCAmelCase		:							Optional[Any]							=     features[self.label_column]
       _UpperCAmelCase		:							int							=     label_schema
       return task_template




     @property
     def        __snake_case(  self    ):
       return {
           self.image_column: "image",
           self.label_column: "labels",
       }





