






"""simple docstring"""






import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding




class 							lowerCAmelCase__				(			UpperCAmelCase__ ):






      '''simple docstring'''

      __UpperCamelCase	 =  ["image_processor", "tokenizer"]
      __UpperCamelCase	 =  "CLIPImageProcessor"
      __UpperCamelCase	 =  ("CLIPTokenizer", "CLIPTokenizerFast")
      def __init__(						self     :  List[Any]						,	lowercase_     :  Dict=None						,	lowercase_     :  List[str]=None						,	**lowercase_     :  List[str]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Tuple    						=		None
          if "feature_extractor" in kwargs:
              warnings.warn(
                  '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
                  ''' instead.'''						,	lowercase_						,	)
              SCREAMING_SNAKE_CASE_      :  List[Any]    						=		kwargs.pop('''feature_extractor''')

          SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		image_processor if image_processor is not None else feature_extractor
          if image_processor is None:
              raise ValueError('''You need to specify an `image_processor`.''')
          if tokenizer is None:
              raise ValueError('''You need to specify a `tokenizer`.''')

          super().__init__(lowercase_						,	lowercase_)
      def __call__(						self     :  str						,	lowercase_     :  int=None						,	lowercase_     :  int=None						,	lowercase_     :  Dict=None						,	**lowercase_     :  Any):




          '''simple docstring'''


          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:
              SCREAMING_SNAKE_CASE_      :  Tuple    						=		self.tokenizer(lowercase_						,	return_tensors=lowercase_						,	**lowercase_)

          if images is not None:
              SCREAMING_SNAKE_CASE_      :  Dict    						=		self.image_processor(lowercase_						,	return_tensors=lowercase_						,	**lowercase_)

          if text is not None and images is not None:
              SCREAMING_SNAKE_CASE_      :  str    						=		image_features.pixel_values
              return encoding
          elif text is not None:
              return encoding
          else:
              return BatchEncoding(data=dict(**lowercase_)						,	tensor_type=lowercase_)
      def _SCREAMING_SNAKE_CASE (						self     :  str						,	*lowercase_     :  int						,	**lowercase_     :  Any):




          '''simple docstring'''


          return self.tokenizer.batch_decode(*lowercase_						,	**lowercase_)
      def _SCREAMING_SNAKE_CASE (						self     :  List[str]						,	*lowercase_     :  Union[str, Any]						,	**lowercase_     :  Optional[int]):




          '''simple docstring'''


          return self.tokenizer.decode(*lowercase_						,	**lowercase_)
      @property
      def _SCREAMING_SNAKE_CASE (						self     :  List[str]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Any    						=		self.tokenizer.model_input_names
          SCREAMING_SNAKE_CASE_      :  Any    						=		self.image_processor.model_input_names
          return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))
      @property
      def _SCREAMING_SNAKE_CASE (						self     :  Optional[int]):




          '''simple docstring'''


          warnings.warn(
              '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''						,	lowercase_						,	)
          return self.image_processor_class



      @property
      def _SCREAMING_SNAKE_CASE (						self     :  List[str]):




          '''simple docstring'''


          warnings.warn(
              '''`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'''						,	lowercase_						,	)
          return self.image_processor










"""simple docstring"""






import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible




class 							lowerCAmelCase__				(			unittest.TestCase ):






      '''simple docstring'''

      def _SCREAMING_SNAKE_CASE (						self     :  str):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  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''',
              '''text_encoder/model.safetensors''',
              '''unet/diffusion_pytorch_model.bin''',
              '''unet/diffusion_pytorch_model.safetensors''',
          ]
          self.assertTrue(is_safetensors_compatible(lowercase_))
      def _SCREAMING_SNAKE_CASE (						self     :  Optional[int]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		[
              '''unet/diffusion_pytorch_model.bin''',
              '''unet/diffusion_pytorch_model.safetensors''',
          ]
          self.assertTrue(is_safetensors_compatible(lowercase_))
      def _SCREAMING_SNAKE_CASE (						self     :  List[str]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  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(lowercase_))
      def _SCREAMING_SNAKE_CASE (						self     :  int):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  List[Any]    						=		[
              '''text_encoder/pytorch_model.bin''',
              '''text_encoder/model.safetensors''',
          ]
          self.assertTrue(is_safetensors_compatible(lowercase_))
      def _SCREAMING_SNAKE_CASE (						self     :  Optional[int]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  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''',
              # Removed: 'text_encoder/model.safetensors',
              '''unet/diffusion_pytorch_model.bin''',
              '''unet/diffusion_pytorch_model.safetensors''',
          ]
          self.assertFalse(is_safetensors_compatible(lowercase_))
      def _SCREAMING_SNAKE_CASE (						self     :  List[Any]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  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''',
          ]
          SCREAMING_SNAKE_CASE_      :  Any    						=		'''fp16'''
          self.assertTrue(is_safetensors_compatible(lowercase_						,	variant=lowercase_))
      def _SCREAMING_SNAKE_CASE (						self     :  str):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		[
              '''unet/diffusion_pytorch_model.fp16.bin''',
              '''unet/diffusion_pytorch_model.fp16.safetensors''',
          ]
          SCREAMING_SNAKE_CASE_      :  Dict    						=		'''fp16'''
          self.assertTrue(is_safetensors_compatible(lowercase_						,	variant=lowercase_))
      def _SCREAMING_SNAKE_CASE (						self     :  int):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  List[str]    						=		[
              '''unet/diffusion_pytorch_model.bin''',
              '''unet/diffusion_pytorch_model.safetensors''',
          ]
          SCREAMING_SNAKE_CASE_      :  Any    						=		'''fp16'''
          self.assertTrue(is_safetensors_compatible(lowercase_						,	variant=lowercase_))
      def _SCREAMING_SNAKE_CASE (						self     :  Union[str, Any]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Tuple    						=		[
              '''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',
          ]
          SCREAMING_SNAKE_CASE_      :  List[Any]    						=		'''fp16'''
          self.assertFalse(is_safetensors_compatible(lowercase_						,	variant=lowercase_))
      def _SCREAMING_SNAKE_CASE (						self     :  List[Any]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  List[Any]    						=		[
              '''text_encoder/pytorch_model.fp16.bin''',
              '''text_encoder/model.fp16.safetensors''',
          ]
          SCREAMING_SNAKE_CASE_      :  Any    						=		'''fp16'''
          self.assertTrue(is_safetensors_compatible(lowercase_						,	variant=lowercase_))
      def _SCREAMING_SNAKE_CASE (						self     :  List[str]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		[
              '''text_encoder/pytorch_model.bin''',
              '''text_encoder/model.safetensors''',
          ]
          SCREAMING_SNAKE_CASE_      :  List[Any]    						=		'''fp16'''
          self.assertTrue(is_safetensors_compatible(lowercase_						,	variant=lowercase_))



      def _SCREAMING_SNAKE_CASE (						self     :  Optional[Any]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  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''',
          ]
          SCREAMING_SNAKE_CASE_      :  str    						=		'''fp16'''
          self.assertFalse(is_safetensors_compatible(lowercase_						,	variant=lowercase_))


