






"""simple docstring"""
import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible



class      SCREAMING_SNAKE_CASE  (				unittest.TestCase						):





	"""simple docstring"""




	def    lowerCamelCase(self							):
		A_		:						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(lowerCAmelCase_							)							)





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





	def    lowerCamelCase(self							):
		A_		:						List[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""",
		    """text_encoder/model.safetensors""",
		    """unet/diffusion_pytorch_model.bin""",
		    # Removed: 'unet/diffusion_pytorch_model.safetensors',
		]
		self.assertFalse(is_safetensors_compatible(lowerCAmelCase_							)							)





	def    lowerCamelCase(self							):
		A_		:						Any	    =   [
		    """text_encoder/pytorch_model.bin""",
		    """text_encoder/model.safetensors""",
		]
		self.assertTrue(is_safetensors_compatible(lowerCAmelCase_							)							)





	def    lowerCamelCase(self							):
		A_		:						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""",
		    # Removed: 'text_encoder/model.safetensors',
		    """unet/diffusion_pytorch_model.bin""",
		    """unet/diffusion_pytorch_model.safetensors""",
		]
		self.assertFalse(is_safetensors_compatible(lowerCAmelCase_							)							)





	def    lowerCamelCase(self							):
		A_		:						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""",
		]
		A_		:						int	    =   """fp16"""
		self.assertTrue(is_safetensors_compatible(lowerCAmelCase_     ,     variant=lowerCAmelCase_							)							)





	def    lowerCamelCase(self							):
		A_		:						Union[str, Any]	    =   [
		    """unet/diffusion_pytorch_model.fp16.bin""",
		    """unet/diffusion_pytorch_model.fp16.safetensors""",
		]
		A_		:						int	    =   """fp16"""
		self.assertTrue(is_safetensors_compatible(lowerCAmelCase_     ,     variant=lowerCAmelCase_							)							)





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





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





	def    lowerCamelCase(self							):
		A_		:						Tuple	    =   [
		    """text_encoder/pytorch_model.fp16.bin""",
		    """text_encoder/model.fp16.safetensors""",
		]
		A_		:						Dict	    =   """fp16"""
		self.assertTrue(is_safetensors_compatible(lowerCAmelCase_     ,     variant=lowerCAmelCase_							)							)





	def    lowerCamelCase(self							):
		# pass variant but use the non-variant filenames
		A_		:						Optional[Any]	    =   [
		    """text_encoder/pytorch_model.bin""",
		    """text_encoder/model.safetensors""",
		]
		A_		:						Optional[int]	    =   """fp16"""
		self.assertTrue(is_safetensors_compatible(lowerCAmelCase_     ,     variant=lowerCAmelCase_							)							)





	def    lowerCamelCase(self							):
		A_		:						Optional[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""",
		    """unet/diffusion_pytorch_model.fp16.safetensors""",
		]
		A_		:						List[str]	    =   """fp16"""
		self.assertFalse(is_safetensors_compatible(lowerCAmelCase_     ,     variant=lowerCAmelCase_							)							)









"""simple docstring"""
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding



class      SCREAMING_SNAKE_CASE  (				_SCREAMING_SNAKE_CASE						):





	"""simple docstring"""




	_A       :				Optional[int]    =				["""image_processor""", """tokenizer"""]
	_A       :				str    =				"""AutoImageProcessor"""
	_A       :				Union[str, Any]    =				"""AutoTokenizer"""





	def __init__(self     ,     lowerCAmelCase_     ,     lowerCAmelCase_							):
		super().__init__(lowerCAmelCase_     ,     lowerCAmelCase_							)
		A_		:						Union[str, Any]	    =   self.image_processor





	def __call__(self     ,     lowerCAmelCase_=None     ,     lowerCAmelCase_=None     ,     lowerCAmelCase_=None     ,     **lowerCAmelCase_							):

		if text is None and images is None:
			raise ValueError("""You have to specify either text or images. Both cannot be none."""							)

		if text is not None:
			A_		:						Optional[int]	    =   self.tokenizer(lowerCAmelCase_     ,     return_tensors=lowerCAmelCase_     ,     **lowerCAmelCase_							)

		if images is not None:
			A_		:						List[Any]	    =   self.image_processor(lowerCAmelCase_     ,     return_tensors=lowerCAmelCase_     ,     **lowerCAmelCase_							)

		if text is not None and images is not None:
			A_		:						int	    =   image_features.pixel_values
			return encoding
		elif text is not None:
			return encoding
		else:
			return BatchEncoding(data=dict(**lowerCAmelCase_							)     ,     tensor_type=lowerCAmelCase_							)





	def    lowerCamelCase(self     ,     *lowerCAmelCase_     ,     **lowerCAmelCase_							):
		return self.tokenizer.batch_decode(*lowerCAmelCase_     ,     **lowerCAmelCase_							)





	def    lowerCamelCase(self     ,     *lowerCAmelCase_     ,     **lowerCAmelCase_							):
		return self.tokenizer.decode(*lowerCAmelCase_     ,     **lowerCAmelCase_							)





	@property
	def    lowerCamelCase(self							):
		return ["input_ids", "attention_mask", "pixel_values"]

