
"""simple docstring"""




import warnings
from typing import List

import numpy as np

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
from ...utils import is_flax_available, is_tf_available, is_torch_available



class 			lowerCAmelCase_		(a__						):


				"""simple docstring"""



				__UpperCamelCase   :		List[str]       =     ['image_processor', 'tokenizer']
				__UpperCamelCase   :		Union[str, Any]       =     'OwlViTImageProcessor'
				__UpperCamelCase   :		Dict       =     ('CLIPTokenizer', 'CLIPTokenizerFast')



				def __init__(self     , SCREAMING_SNAKE_CASE__=None     , SCREAMING_SNAKE_CASE__=None     , **SCREAMING_SNAKE_CASE__					)      ->	int:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     None
											if "feature_extractor" in kwargs:
																		warnings.warn(
																		    """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
																		    """ instead."""     , SCREAMING_SNAKE_CASE__     , )
																		SCREAMING_SNAKE_CASE__		: str     =     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__(SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__					)



				def __call__(self     , SCREAMING_SNAKE_CASE__=None     , SCREAMING_SNAKE_CASE__=None     , SCREAMING_SNAKE_CASE__=None     , SCREAMING_SNAKE_CASE__="max_length"     , SCREAMING_SNAKE_CASE__="np"     , **SCREAMING_SNAKE_CASE__					)      ->	Union[str, Any]:



											"""simple docstring"""




											if text is None and query_images is None and images is None:
																		raise ValueError(
																		    """You have to specify at least one text or query image or image. All three cannot be none."""					)

											if text is not None:
																		if isinstance(SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__					) or (isinstance(SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__					) and not isinstance(text[0]     , SCREAMING_SNAKE_CASE__					)):
																									SCREAMING_SNAKE_CASE__		: Tuple     =     [self.tokenizer(SCREAMING_SNAKE_CASE__     , padding=SCREAMING_SNAKE_CASE__     , return_tensors=SCREAMING_SNAKE_CASE__     , **SCREAMING_SNAKE_CASE__					)]

																		elif isinstance(SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__					) and isinstance(text[0]     , SCREAMING_SNAKE_CASE__					):
																									SCREAMING_SNAKE_CASE__		: Optional[int]     =     []

																									# Maximum number of queries across batch
																									SCREAMING_SNAKE_CASE__		: str     =     max([len(SCREAMING_SNAKE_CASE__					) for t in text]					)

																									# Pad all batch samples to max number of text queries
																									for t in text:
																																if len(SCREAMING_SNAKE_CASE__					) != max_num_queries:
																																							SCREAMING_SNAKE_CASE__		: Any     =     t + [""" """] * (max_num_queries - len(SCREAMING_SNAKE_CASE__					))

																																SCREAMING_SNAKE_CASE__		: Optional[Any]     =     self.tokenizer(SCREAMING_SNAKE_CASE__     , padding=SCREAMING_SNAKE_CASE__     , return_tensors=SCREAMING_SNAKE_CASE__     , **SCREAMING_SNAKE_CASE__					)
																																encodings.append(SCREAMING_SNAKE_CASE__					)
																		else:
																									raise TypeError("""Input text should be a string, a list of strings or a nested list of strings"""					)

																		if return_tensors == "np":
																									SCREAMING_SNAKE_CASE__		: int     =     np.concatenate([encoding["""input_ids"""] for encoding in encodings]     , axis=0					)
																									SCREAMING_SNAKE_CASE__		: Dict     =     np.concatenate([encoding["""attention_mask"""] for encoding in encodings]     , axis=0					)

																		elif return_tensors == "jax" and is_flax_available():
																									import jax.numpy as jnp

																									SCREAMING_SNAKE_CASE__		: Tuple     =     jnp.concatenate([encoding["""input_ids"""] for encoding in encodings]     , axis=0					)
																									SCREAMING_SNAKE_CASE__		: str     =     jnp.concatenate([encoding["""attention_mask"""] for encoding in encodings]     , axis=0					)

																		elif return_tensors == "pt" and is_torch_available():
																									import torch

																									SCREAMING_SNAKE_CASE__		: List[Any]     =     torch.cat([encoding["""input_ids"""] for encoding in encodings]     , dim=0					)
																									SCREAMING_SNAKE_CASE__		: str     =     torch.cat([encoding["""attention_mask"""] for encoding in encodings]     , dim=0					)

																		elif return_tensors == "tf" and is_tf_available():
																									import tensorflow as tf

																									SCREAMING_SNAKE_CASE__		: str     =     tf.stack([encoding["""input_ids"""] for encoding in encodings]     , axis=0					)
																									SCREAMING_SNAKE_CASE__		: Tuple     =     tf.stack([encoding["""attention_mask"""] for encoding in encodings]     , axis=0					)

																		else:
																									raise ValueError("""Target return tensor type could not be returned"""					)

																		SCREAMING_SNAKE_CASE__		: Union[str, Any]     =     BatchEncoding()
																		SCREAMING_SNAKE_CASE__		: Tuple     =     input_ids
																		SCREAMING_SNAKE_CASE__		: str     =     attention_mask

											if query_images is not None:
																		SCREAMING_SNAKE_CASE__		: int     =     BatchEncoding()
																		SCREAMING_SNAKE_CASE__		: List[str]     =     self.image_processor(
																		    SCREAMING_SNAKE_CASE__     , return_tensors=SCREAMING_SNAKE_CASE__     , **SCREAMING_SNAKE_CASE__					).pixel_values
																		SCREAMING_SNAKE_CASE__		: List[Any]     =     query_pixel_values

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

											if text is not None and images is not None:
																		SCREAMING_SNAKE_CASE__		: int     =     image_features.pixel_values
																		return encoding
											elif query_images is not None and images is not None:
																		SCREAMING_SNAKE_CASE__		: List[Any]     =     image_features.pixel_values
																		return encoding
											elif text is not None or query_images is not None:
																		return encoding
											else:
																		return BatchEncoding(data=dict(**SCREAMING_SNAKE_CASE__					)     , tensor_type=SCREAMING_SNAKE_CASE__					)



				def 			__magic_name__					(self     , *SCREAMING_SNAKE_CASE__     , **SCREAMING_SNAKE_CASE__					)      ->	List[str]:



											"""simple docstring"""




											return self.image_processor.post_process(*SCREAMING_SNAKE_CASE__     , **SCREAMING_SNAKE_CASE__					)



				def 			__magic_name__					(self     , *SCREAMING_SNAKE_CASE__     , **SCREAMING_SNAKE_CASE__					)      ->	Optional[Any]:



											"""simple docstring"""




											return self.image_processor.post_process_object_detection(*SCREAMING_SNAKE_CASE__     , **SCREAMING_SNAKE_CASE__					)



				def 			__magic_name__					(self     , *SCREAMING_SNAKE_CASE__     , **SCREAMING_SNAKE_CASE__					)      ->	int:



											"""simple docstring"""




											return self.image_processor.post_process_image_guided_detection(*SCREAMING_SNAKE_CASE__     , **SCREAMING_SNAKE_CASE__					)



				def 			__magic_name__					(self     , *SCREAMING_SNAKE_CASE__     , **SCREAMING_SNAKE_CASE__					)      ->	Union[str, Any]:



											"""simple docstring"""




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



				def 			__magic_name__					(self     , *SCREAMING_SNAKE_CASE__     , **SCREAMING_SNAKE_CASE__					)      ->	Optional[Any]:



											"""simple docstring"""




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



				@property
				def 			__magic_name__					(self					)      ->	str:



											"""simple docstring"""




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



				@property
				def 			__magic_name__					(self					)      ->	Tuple:



											"""simple docstring"""




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






"""simple docstring"""




def lowercase_						(     _snake_case     ,_snake_case		):
							return int((input_a, input_a).count(1		) != 0		)

def lowercase_						(     ):
							assert or_gate(0     ,0		) == 0
							assert or_gate(0     ,1		) == 1
							assert or_gate(1     ,0		) == 1
							assert or_gate(1     ,1		) == 1


if __name__ == "__main__":
					print(or_gate(0, 1))
					print(or_gate(1, 0))
					print(or_gate(0, 0))
					print(or_gate(1, 1))




