'''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 							a__(   lowerCAmelCase__      ):


			'''simple docstring'''






			UpperCAmelCase_     :	Any						=			['''image_processor''', '''tokenizer''']
			UpperCAmelCase_     :	Optional[Any]						=			'''OwlViTImageProcessor'''
			UpperCAmelCase_     :	List[str]						=			('''CLIPTokenizer''', '''CLIPTokenizerFast''')



			def __init__(  self			,       __lowerCAmelCase=None			,       __lowerCAmelCase=None			,       **__lowerCAmelCase):




					"""simple docstring"""


					lowerCAmelCase     =    None
					if "feature_extractor" in kwargs:
							warnings.warn(
							    """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
							    """ instead."""			,       __lowerCAmelCase			,       )
							lowerCAmelCase     =    kwargs.pop("""feature_extractor""")

					lowerCAmelCase     =    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__(__lowerCAmelCase			,       __lowerCAmelCase)



			def __call__(  self			,       __lowerCAmelCase=None			,       __lowerCAmelCase=None			,       __lowerCAmelCase=None			,       __lowerCAmelCase="max_length"			,       __lowerCAmelCase="np"			,       **__lowerCAmelCase):




					"""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(__lowerCAmelCase			,       __lowerCAmelCase) or (isinstance(__lowerCAmelCase			,       __lowerCAmelCase) and not isinstance(text[0]			,       __lowerCAmelCase)):
									lowerCAmelCase     =    [self.tokenizer(__lowerCAmelCase			,       padding=__lowerCAmelCase			,       return_tensors=__lowerCAmelCase			,       **__lowerCAmelCase)]

							elif isinstance(__lowerCAmelCase			,       __lowerCAmelCase) and isinstance(text[0]			,       __lowerCAmelCase):
									lowerCAmelCase     =    []

									# Maximum number of queries across batch
									lowerCAmelCase     =    max([len(__lowerCAmelCase) for t in text])

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

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

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

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

									lowerCAmelCase     =    jnp.concatenate([encoding["""input_ids"""] for encoding in encodings]			,       axis=0)
									lowerCAmelCase     =    jnp.concatenate([encoding["""attention_mask"""] for encoding in encodings]			,       axis=0)

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

									lowerCAmelCase     =    torch.cat([encoding["""input_ids"""] for encoding in encodings]			,       dim=0)
									lowerCAmelCase     =    torch.cat([encoding["""attention_mask"""] for encoding in encodings]			,       dim=0)

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

									lowerCAmelCase     =    tf.stack([encoding["""input_ids"""] for encoding in encodings]			,       axis=0)
									lowerCAmelCase     =    tf.stack([encoding["""attention_mask"""] for encoding in encodings]			,       axis=0)

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

							lowerCAmelCase     =    BatchEncoding()
							lowerCAmelCase     =    input_ids
							lowerCAmelCase     =    attention_mask

					if query_images is not None:
							lowerCAmelCase     =    BatchEncoding()
							lowerCAmelCase     =    self.image_processor(
							    __lowerCAmelCase			,       return_tensors=__lowerCAmelCase			,       **__lowerCAmelCase).pixel_values
							lowerCAmelCase     =    query_pixel_values

					if images is not None:
							lowerCAmelCase     =    self.image_processor(__lowerCAmelCase			,       return_tensors=__lowerCAmelCase			,       **__lowerCAmelCase)

					if text is not None and images is not None:
							lowerCAmelCase     =    image_features.pixel_values
							return encoding
					elif query_images is not None and images is not None:
							lowerCAmelCase     =    image_features.pixel_values
							return encoding
					elif text is not None or query_images is not None:
							return encoding
					else:
							return BatchEncoding(data=dict(**__lowerCAmelCase)			,       tensor_type=__lowerCAmelCase)



			def 				a_			(  self			,       *__lowerCAmelCase			,       **__lowerCAmelCase):




					"""simple docstring"""


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



			def 				a_			(  self			,       *__lowerCAmelCase			,       **__lowerCAmelCase):




					"""simple docstring"""


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



			def 				a_			(  self			,       *__lowerCAmelCase			,       **__lowerCAmelCase):




					"""simple docstring"""


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



			def 				a_			(  self			,       *__lowerCAmelCase			,       **__lowerCAmelCase):




					"""simple docstring"""


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



			def 				a_			(  self			,       *__lowerCAmelCase			,       **__lowerCAmelCase):




					"""simple docstring"""


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



			@property
			def 				a_			(  self):




					"""simple docstring"""


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







			@property
			def 				a_			(  self):




					"""simple docstring"""


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





'''simple docstring'''




from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig


__lowercase        =    {
    '''albert-base-v1''': '''https://huggingface.co/albert-base-v1/resolve/main/config.json''',
    '''albert-large-v1''': '''https://huggingface.co/albert-large-v1/resolve/main/config.json''',
    '''albert-xlarge-v1''': '''https://huggingface.co/albert-xlarge-v1/resolve/main/config.json''',
    '''albert-xxlarge-v1''': '''https://huggingface.co/albert-xxlarge-v1/resolve/main/config.json''',
    '''albert-base-v2''': '''https://huggingface.co/albert-base-v2/resolve/main/config.json''',
    '''albert-large-v2''': '''https://huggingface.co/albert-large-v2/resolve/main/config.json''',
    '''albert-xlarge-v2''': '''https://huggingface.co/albert-xlarge-v2/resolve/main/config.json''',
    '''albert-xxlarge-v2''': '''https://huggingface.co/albert-xxlarge-v2/resolve/main/config.json''',
}






class 							a__(   lowerCAmelCase__      ):


			'''simple docstring'''






			UpperCAmelCase_     :	List[str]						=			'''albert'''



			def __init__(  self			,       __lowerCAmelCase=30000			,       __lowerCAmelCase=128			,       __lowerCAmelCase=4096			,       __lowerCAmelCase=12			,       __lowerCAmelCase=1			,       __lowerCAmelCase=64			,       __lowerCAmelCase=16384			,       __lowerCAmelCase=1			,       __lowerCAmelCase="gelu_new"			,       __lowerCAmelCase=0			,       __lowerCAmelCase=0			,       __lowerCAmelCase=512			,       __lowerCAmelCase=2			,       __lowerCAmelCase=0.02			,       __lowerCAmelCase=1E-1_2			,       __lowerCAmelCase=0.1			,       __lowerCAmelCase="absolute"			,       __lowerCAmelCase=0			,       __lowerCAmelCase=2			,       __lowerCAmelCase=3			,       **__lowerCAmelCase			,       ):




					"""simple docstring"""


					super().__init__(pad_token_id=__lowerCAmelCase			,       bos_token_id=__lowerCAmelCase			,       eos_token_id=__lowerCAmelCase			,       **__lowerCAmelCase)

					lowerCAmelCase     =    vocab_size
					lowerCAmelCase     =    embedding_size
					lowerCAmelCase     =    hidden_size
					lowerCAmelCase     =    num_hidden_layers
					lowerCAmelCase     =    num_hidden_groups
					lowerCAmelCase     =    num_attention_heads
					lowerCAmelCase     =    inner_group_num
					lowerCAmelCase     =    hidden_act
					lowerCAmelCase     =    intermediate_size
					lowerCAmelCase     =    hidden_dropout_prob
					lowerCAmelCase     =    attention_probs_dropout_prob
					lowerCAmelCase     =    max_position_embeddings
					lowerCAmelCase     =    type_vocab_size
					lowerCAmelCase     =    initializer_range
					lowerCAmelCase     =    layer_norm_eps
					lowerCAmelCase     =    classifier_dropout_prob
					lowerCAmelCase     =    position_embedding_type







class 							a__(   lowerCAmelCase__      ):


			'''simple docstring'''






			@property
			def 				a_			(  self):




					"""simple docstring"""


					if self.task == "multiple-choice":
							lowerCAmelCase     =    {0: """batch""", 1: """choice""", 2: """sequence"""}
					else:
							lowerCAmelCase     =    {0: """batch""", 1: """sequence"""}
					return OrderedDict(
					    [
					        ("""input_ids""", dynamic_axis),
					        ("""attention_mask""", dynamic_axis),
					        ("""token_type_ids""", dynamic_axis),
					    ])




