




from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType



class       a_       (     SCREAMING_SNAKE_CASE__     ):
	A    							= ['''image_processor''', '''tokenizer''']
	A    							= '''BlipImageProcessor'''
	A    							= ('''BertTokenizer''', '''BertTokenizerFast''')





	def __init__(							self      ,     SCREAMING_SNAKE_CASE      ,     SCREAMING_SNAKE_CASE      )  ->					List[Any]:




				"""simple docstring"""



				SCREAMING_SNAKE_CASE_								=						False
				super().__init__(SCREAMING_SNAKE_CASE      ,     SCREAMING_SNAKE_CASE      )
				SCREAMING_SNAKE_CASE_								=						self.image_processor





	def __call__(							self      ,     SCREAMING_SNAKE_CASE = None      ,     SCREAMING_SNAKE_CASE = None      ,     SCREAMING_SNAKE_CASE = True      ,     SCREAMING_SNAKE_CASE = False      ,     SCREAMING_SNAKE_CASE = None      ,     SCREAMING_SNAKE_CASE = None      ,     SCREAMING_SNAKE_CASE = 0      ,     SCREAMING_SNAKE_CASE = None      ,     SCREAMING_SNAKE_CASE = None      ,     SCREAMING_SNAKE_CASE = False      ,     SCREAMING_SNAKE_CASE = False      ,     SCREAMING_SNAKE_CASE = False      ,     SCREAMING_SNAKE_CASE = False      ,     SCREAMING_SNAKE_CASE = False      ,     SCREAMING_SNAKE_CASE = True      ,     SCREAMING_SNAKE_CASE = None      ,     **SCREAMING_SNAKE_CASE      ,     )  ->					BatchEncoding:




				"""simple docstring"""



				if images is None and text is None:
							raise ValueError('You have to specify either images or text.'      )

				# Get only text
				if images is None:
							SCREAMING_SNAKE_CASE_								=						self.tokenizer
							SCREAMING_SNAKE_CASE_								=						self.tokenizer(
							    text=SCREAMING_SNAKE_CASE      ,     add_special_tokens=SCREAMING_SNAKE_CASE      ,     padding=SCREAMING_SNAKE_CASE      ,     truncation=SCREAMING_SNAKE_CASE      ,     max_length=SCREAMING_SNAKE_CASE      ,     stride=SCREAMING_SNAKE_CASE      ,     pad_to_multiple_of=SCREAMING_SNAKE_CASE      ,     return_attention_mask=SCREAMING_SNAKE_CASE      ,     return_overflowing_tokens=SCREAMING_SNAKE_CASE      ,     return_special_tokens_mask=SCREAMING_SNAKE_CASE      ,     return_offsets_mapping=SCREAMING_SNAKE_CASE      ,     return_token_type_ids=SCREAMING_SNAKE_CASE      ,     return_length=SCREAMING_SNAKE_CASE      ,     verbose=SCREAMING_SNAKE_CASE      ,     return_tensors=SCREAMING_SNAKE_CASE      ,     **SCREAMING_SNAKE_CASE      ,     )
							return text_encoding

				# add pixel_values
				SCREAMING_SNAKE_CASE_								=						self.image_processor(SCREAMING_SNAKE_CASE      ,     return_tensors=SCREAMING_SNAKE_CASE      )

				if text is not None:
							SCREAMING_SNAKE_CASE_								=						self.tokenizer(
							    text=SCREAMING_SNAKE_CASE      ,     add_special_tokens=SCREAMING_SNAKE_CASE      ,     padding=SCREAMING_SNAKE_CASE      ,     truncation=SCREAMING_SNAKE_CASE      ,     max_length=SCREAMING_SNAKE_CASE      ,     stride=SCREAMING_SNAKE_CASE      ,     pad_to_multiple_of=SCREAMING_SNAKE_CASE      ,     return_attention_mask=SCREAMING_SNAKE_CASE      ,     return_overflowing_tokens=SCREAMING_SNAKE_CASE      ,     return_special_tokens_mask=SCREAMING_SNAKE_CASE      ,     return_offsets_mapping=SCREAMING_SNAKE_CASE      ,     return_token_type_ids=SCREAMING_SNAKE_CASE      ,     return_length=SCREAMING_SNAKE_CASE      ,     verbose=SCREAMING_SNAKE_CASE      ,     return_tensors=SCREAMING_SNAKE_CASE      ,     **SCREAMING_SNAKE_CASE      ,     )
				else:
							SCREAMING_SNAKE_CASE_								=						None

				if text_encoding is not None:
							encoding_image_processor.update(SCREAMING_SNAKE_CASE      )

				return encoding_image_processor





	def 						A_(							self      ,     *SCREAMING_SNAKE_CASE      ,     **SCREAMING_SNAKE_CASE      )  ->					int:




				"""simple docstring"""



				return self.tokenizer.batch_decode(*SCREAMING_SNAKE_CASE      ,     **SCREAMING_SNAKE_CASE      )





	def 						A_(							self      ,     *SCREAMING_SNAKE_CASE      ,     **SCREAMING_SNAKE_CASE      )  ->					List[str]:




				"""simple docstring"""



				return self.tokenizer.decode(*SCREAMING_SNAKE_CASE      ,     **SCREAMING_SNAKE_CASE      )





	@property
	def 						A_(							self      )  ->					int:




				"""simple docstring"""



				SCREAMING_SNAKE_CASE_								=						self.tokenizer.model_input_names
				SCREAMING_SNAKE_CASE_								=						self.image_processor.model_input_names
				return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names      )      )






import unittest

from diffusers import FlaxAutoencoderKL
from diffusers.utils import is_flax_available
from diffusers.utils.testing_utils import require_flax

from .test_modeling_common_flax import FlaxModelTesterMixin


if is_flax_available():
				import jax



@require_flax
class       a_       (     SCREAMING_SNAKE_CASE__  ,    unittest.TestCase     ):
	A    							= FlaxAutoencoderKL





	@property
	def 						A_(							self      )  ->					Optional[Any]:




				"""simple docstring"""



				SCREAMING_SNAKE_CASE_								=						4
				SCREAMING_SNAKE_CASE_								=						3
				SCREAMING_SNAKE_CASE_								=						(32, 32)

				SCREAMING_SNAKE_CASE_								=						jax.random.PRNGKey(0      )
				SCREAMING_SNAKE_CASE_								=						jax.random.uniform(SCREAMING_SNAKE_CASE      ,     ((batch_size, num_channels) + sizes)      )

				return {"sample": image, "prng_key": prng_key}





	def 						A_(							self      )  ->					Tuple:




				"""simple docstring"""



				SCREAMING_SNAKE_CASE_								=						{
				    'block_out_channels': [32, 64],
				    'in_channels': 3,
				    'out_channels': 3,
				    'down_block_types': ['DownEncoderBlock2D', 'DownEncoderBlock2D'],
				    'up_block_types': ['UpDecoderBlock2D', 'UpDecoderBlock2D'],
				    'latent_channels': 4,
				}
				SCREAMING_SNAKE_CASE_								=						self.dummy_input
				return init_dict, inputs_dict
