'''simple docstring'''





import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible




class 	__A				(			unittest.TestCase     ):



				def  _lowercase						(self   :   List[str]			):
									UpperCAmelCase_	   =       [
									    "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(_SCREAMING_SNAKE_CASE			)			)



				def  _lowercase						(self   :   Any			):
									UpperCAmelCase_	   =       [
									    "unet/diffusion_pytorch_model.bin",
									    "unet/diffusion_pytorch_model.safetensors",
									]
									self.assertTrue(is_safetensors_compatible(_SCREAMING_SNAKE_CASE			)			)



				def  _lowercase						(self   :   Any			):
									UpperCAmelCase_	   =       [
									    "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(_SCREAMING_SNAKE_CASE			)			)



				def  _lowercase						(self   :   List[str]			):
									UpperCAmelCase_	   =       [
									    "text_encoder/pytorch_model.bin",
									    "text_encoder/model.safetensors",
									]
									self.assertTrue(is_safetensors_compatible(_SCREAMING_SNAKE_CASE			)			)



				def  _lowercase						(self   :   List[str]			):
									UpperCAmelCase_	   =       [
									    "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(_SCREAMING_SNAKE_CASE			)			)



				def  _lowercase						(self   :   Union[str, Any]			):
									UpperCAmelCase_	   =       [
									    "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_	   =       "fp16"
									self.assertTrue(is_safetensors_compatible(_SCREAMING_SNAKE_CASE       ,      variant=_SCREAMING_SNAKE_CASE			)			)



				def  _lowercase						(self   :   str			):
									UpperCAmelCase_	   =       [
									    "unet/diffusion_pytorch_model.fp16.bin",
									    "unet/diffusion_pytorch_model.fp16.safetensors",
									]
									UpperCAmelCase_	   =       "fp16"
									self.assertTrue(is_safetensors_compatible(_SCREAMING_SNAKE_CASE       ,      variant=_SCREAMING_SNAKE_CASE			)			)



				def  _lowercase						(self   :   Union[str, Any]			):
									# pass variant but use the non-variant filenames
									UpperCAmelCase_	   =       [
									    "unet/diffusion_pytorch_model.bin",
									    "unet/diffusion_pytorch_model.safetensors",
									]
									UpperCAmelCase_	   =       "fp16"
									self.assertTrue(is_safetensors_compatible(_SCREAMING_SNAKE_CASE       ,      variant=_SCREAMING_SNAKE_CASE			)			)



				def  _lowercase						(self   :   int			):
									UpperCAmelCase_	   =       [
									    "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_	   =       "fp16"
									self.assertFalse(is_safetensors_compatible(_SCREAMING_SNAKE_CASE       ,      variant=_SCREAMING_SNAKE_CASE			)			)



				def  _lowercase						(self   :   str			):
									UpperCAmelCase_	   =       [
									    "text_encoder/pytorch_model.fp16.bin",
									    "text_encoder/model.fp16.safetensors",
									]
									UpperCAmelCase_	   =       "fp16"
									self.assertTrue(is_safetensors_compatible(_SCREAMING_SNAKE_CASE       ,      variant=_SCREAMING_SNAKE_CASE			)			)



				def  _lowercase						(self   :   List[str]			):
									# pass variant but use the non-variant filenames
									UpperCAmelCase_	   =       [
									    "text_encoder/pytorch_model.bin",
									    "text_encoder/model.safetensors",
									]
									UpperCAmelCase_	   =       "fp16"
									self.assertTrue(is_safetensors_compatible(_SCREAMING_SNAKE_CASE       ,      variant=_SCREAMING_SNAKE_CASE			)			)






				def  _lowercase						(self   :   str			):
									UpperCAmelCase_	   =       [
									    "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_	   =       "fp16"
									self.assertFalse(is_safetensors_compatible(_SCREAMING_SNAKE_CASE       ,      variant=_SCREAMING_SNAKE_CASE			)			)





'''simple docstring'''





from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


SCREAMING_SNAKE_CASE_:					List[str]  =logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_:					Tuple  ={
    'microsoft/resnet-50': 'https://huggingface.co/microsoft/resnet-50/blob/main/config.json',
}




class 	__A				(			UpperCamelCase__		,     UpperCamelCase__     ):
    a__	:						Optional[Any]	       =  """resnet"""
    a__	:						Tuple	       =  ["""basic""", """bottleneck"""]



    def __init__(self   :   List[Any]       ,      __a   :   Any=3       ,      __a   :   Dict=64       ,      __a   :   Union[str, Any]=[256, 512, 1024, 2048]       ,      __a   :   str=[3, 4, 6, 3]       ,      __a   :   Optional[Any]="bottleneck"       ,      __a   :   Tuple="relu"       ,      __a   :   int=False       ,      __a   :   Optional[int]=None       ,      __a   :   str=None       ,      **__a   :   Dict       ,      ):
         super().__init__(**__a			)
         if layer_type not in self.layer_types:
              raise ValueError(f"""layer_type={layer_type} is not one of {",".join(self.layer_types			)}"""			)
         UpperCAmelCase_	   =       num_channels
         UpperCAmelCase_	   =       embedding_size
         UpperCAmelCase_	   =       hidden_sizes
         UpperCAmelCase_	   =       depths
         UpperCAmelCase_	   =       layer_type
         UpperCAmelCase_	   =       hidden_act
         UpperCAmelCase_	   =       downsample_in_first_stage
         UpperCAmelCase_	   =       ["stem"] + [f"""stage{idx}""" for idx in range(1       ,      len(__a			) + 1			)]
         UpperCAmelCase_   ,			UpperCAmelCase_	   =       get_aligned_output_features_output_indices(
             out_features=__a       ,      out_indices=__a       ,      stage_names=self.stage_names			)




class 	__A				(			UpperCamelCase__     ):
    a__	:						int	       =  version.parse("""1.11"""     )



    @property
    def  _lowercase						(self   :   Optional[int]			):
         return OrderedDict(
             [
                 ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
             ]			)






    @property
    def  _lowercase						(self   :   str			):
         return 1E-3




