


from dataclasses import dataclass
from typing import Optional

import numpy as np
import torch
import torch.nn as nn

from ..utils import BaseOutput, is_torch_version, randn_tensor
from .attention_processor import SpatialNorm
from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block

@dataclass
class     a		(_lowerCAmelCase				):




							"""simple docstring"""


							__UpperCAmelCase   :							torch.FloatTensor

class     a		(nn.Module				):




							"""simple docstring"""


							def __init__(							self	:  Optional[int]   ,     lowerCamelCase	:  Any=3   ,     lowerCamelCase	:  List[str]=3   ,     lowerCamelCase	:  List[str]=("DownEncoderBlock2D",)   ,     lowerCamelCase	:  List[str]=(64,)   ,     lowerCamelCase	:  int=2   ,     lowerCamelCase	:  Tuple=32   ,     lowerCamelCase	:  Union[str, Any]="silu"   ,     lowerCamelCase	:  int=True   ,     )     ->   int:
														super().__init__()
														__snake_case		:      Dict										=       layers_per_block

														__snake_case		:      Optional[int]										=       torch.nn.Convad(
														    lowerCamelCase   ,     block_out_channels[0]   ,     kernel_size=3   ,     stride=1   ,     padding=1   ,     )

														__snake_case		:      str										=       None
														__snake_case		:      Any										=       nn.ModuleList([]    )

														# down
														__snake_case		:      Optional[int]										=       block_out_channels[0]
														for i, down_block_type in enumerate(lowerCamelCase    ):
																					__snake_case		:      int										=       output_channel
																					__snake_case		:      List[Any]										=       block_out_channels[i]
																					__snake_case		:      Any										=       i == len(lowerCamelCase    ) - 1

																					__snake_case		:      Any										=       get_down_block(
																					    lowerCamelCase   ,     num_layers=self.layers_per_block   ,     in_channels=lowerCamelCase   ,     out_channels=lowerCamelCase   ,     add_downsample=not is_final_block   ,     resnet_eps=1E-6   ,     downsample_padding=0   ,     resnet_act_fn=lowerCamelCase   ,     resnet_groups=lowerCamelCase   ,     attention_head_dim=lowerCamelCase   ,     temb_channels=lowerCamelCase   ,     )
																					self.down_blocks.append(lowerCamelCase    )

														# mid
														__snake_case		:      Optional[int]										=       UNetMidBlockaD(
														    in_channels=block_out_channels[-1]   ,     resnet_eps=1E-6   ,     resnet_act_fn=lowerCamelCase   ,     output_scale_factor=1   ,     resnet_time_scale_shift="default"   ,     attention_head_dim=block_out_channels[-1]   ,     resnet_groups=lowerCamelCase   ,     temb_channels=lowerCamelCase   ,     )

														# out
														__snake_case		:      Union[str, Any]										=       nn.GroupNorm(num_channels=block_out_channels[-1]   ,     num_groups=lowerCamelCase   ,     eps=1E-6    )
														__snake_case		:      str										=       nn.SiLU()

														__snake_case		:      List[Any]										=       2 * out_channels if double_z else out_channels
														__snake_case		:      int										=       nn.Convad(block_out_channels[-1]   ,     lowerCamelCase   ,     3   ,     padding=1    )

														__snake_case		:      Tuple										=       False






							def    __snake_case (							self	:  Tuple   ,     lowerCamelCase	:  str    )     ->   Optional[Any]:
														__snake_case		:      int										=       x
														__snake_case		:      Optional[Any]										=       self.conv_in(lowerCamelCase    )

														if self.training and self.gradient_checkpointing:

																					def create_custom_forward(lowerCamelCase	:  Any    ):
																												def custom_forward(*lowerCamelCase	:  List[str]    ):
																																			return module(*lowerCamelCase    )

																												return custom_forward

																					# down
																					if is_torch_version(">="   ,     "1.11.0"    ):
																												for down_block in self.down_blocks:
																																			__snake_case		:      str										=       torch.utils.checkpoint.checkpoint(
																																			    create_custom_forward(lowerCamelCase    )   ,     lowerCamelCase   ,     use_reentrant=lowerCamelCase    )
																												# middle
																												__snake_case		:      Optional[Any]										=       torch.utils.checkpoint.checkpoint(
																												    create_custom_forward(self.mid_block    )   ,     lowerCamelCase   ,     use_reentrant=lowerCamelCase    )
																					else:
																												for down_block in self.down_blocks:
																																			__snake_case		:      int										=       torch.utils.checkpoint.checkpoint(create_custom_forward(lowerCamelCase    )   ,     lowerCamelCase    )
																												# middle
																												__snake_case		:      Optional[Any]										=       torch.utils.checkpoint.checkpoint(create_custom_forward(self.mid_block    )   ,     lowerCamelCase    )

														else:
																					# down
																					for down_block in self.down_blocks:
																												__snake_case		:      Union[str, Any]										=       down_block(lowerCamelCase    )

																					# middle
																					__snake_case		:      List[Any]										=       self.mid_block(lowerCamelCase    )

														# post-process
														__snake_case		:      Any										=       self.conv_norm_out(lowerCamelCase    )
														__snake_case		:      Union[str, Any]										=       self.conv_act(lowerCamelCase    )
														__snake_case		:      int										=       self.conv_out(lowerCamelCase    )

														return sample

class     a		(nn.Module				):




							"""simple docstring"""


							def __init__(							self	:  Any   ,     lowerCamelCase	:  Tuple=3   ,     lowerCamelCase	:  Optional[Any]=3   ,     lowerCamelCase	:  Any=("UpDecoderBlock2D",)   ,     lowerCamelCase	:  int=(64,)   ,     lowerCamelCase	:  Union[str, Any]=2   ,     lowerCamelCase	:  List[Any]=32   ,     lowerCamelCase	:  Any="silu"   ,     lowerCamelCase	:  str="group"   ,     )     ->   Union[str, Any]:
														super().__init__()
														__snake_case		:      Optional[int]										=       layers_per_block

														__snake_case		:      int										=       nn.Convad(
														    lowerCamelCase   ,     block_out_channels[-1]   ,     kernel_size=3   ,     stride=1   ,     padding=1   ,     )

														__snake_case		:      List[Any]										=       None
														__snake_case		:      List[str]										=       nn.ModuleList([]    )

														__snake_case		:      Any										=       in_channels if norm_type == "spatial" else None

														# mid
														__snake_case		:      Dict										=       UNetMidBlockaD(
														    in_channels=block_out_channels[-1]   ,     resnet_eps=1E-6   ,     resnet_act_fn=lowerCamelCase   ,     output_scale_factor=1   ,     resnet_time_scale_shift="default" if norm_type == "group" else norm_type   ,     attention_head_dim=block_out_channels[-1]   ,     resnet_groups=lowerCamelCase   ,     temb_channels=lowerCamelCase   ,     )

														# up
														__snake_case		:      List[str]										=       list(reversed(lowerCamelCase    )    )
														__snake_case		:      Optional[Any]										=       reversed_block_out_channels[0]
														for i, up_block_type in enumerate(lowerCamelCase    ):
																					__snake_case		:      str										=       output_channel
																					__snake_case		:      int										=       reversed_block_out_channels[i]

																					__snake_case		:      List[str]										=       i == len(lowerCamelCase    ) - 1

																					__snake_case		:      Optional[Any]										=       get_up_block(
																					    lowerCamelCase   ,     num_layers=self.layers_per_block + 1   ,     in_channels=lowerCamelCase   ,     out_channels=lowerCamelCase   ,     prev_output_channel=lowerCamelCase   ,     add_upsample=not is_final_block   ,     resnet_eps=1E-6   ,     resnet_act_fn=lowerCamelCase   ,     resnet_groups=lowerCamelCase   ,     attention_head_dim=lowerCamelCase   ,     temb_channels=lowerCamelCase   ,     resnet_time_scale_shift=lowerCamelCase   ,     )
																					self.up_blocks.append(lowerCamelCase    )
																					__snake_case		:      Optional[Any]										=       output_channel

														# out
														if norm_type == "spatial":
																					__snake_case		:      Optional[Any]										=       SpatialNorm(block_out_channels[0]   ,     lowerCamelCase    )
														else:
																					__snake_case		:      List[str]										=       nn.GroupNorm(num_channels=block_out_channels[0]   ,     num_groups=lowerCamelCase   ,     eps=1E-6    )
														__snake_case		:      Dict										=       nn.SiLU()
														__snake_case		:      Any										=       nn.Convad(block_out_channels[0]   ,     lowerCamelCase   ,     3   ,     padding=1    )

														__snake_case		:      str										=       False






							def    __snake_case (							self	:  Tuple   ,     lowerCamelCase	:  Dict   ,     lowerCamelCase	:  Union[str, Any]=None    )     ->   Optional[Any]:
														__snake_case		:      str										=       z
														__snake_case		:      Tuple										=       self.conv_in(lowerCamelCase    )

														__snake_case		:      int										=       next(iter(self.up_blocks.parameters()    )    ).dtype
														if self.training and self.gradient_checkpointing:

																					def create_custom_forward(lowerCamelCase	:  str    ):
																												def custom_forward(*lowerCamelCase	:  Optional[Any]    ):
																																			return module(*lowerCamelCase    )

																												return custom_forward

																					if is_torch_version(">="   ,     "1.11.0"    ):
																												# middle
																												__snake_case		:      Optional[int]										=       torch.utils.checkpoint.checkpoint(
																												    create_custom_forward(self.mid_block    )   ,     lowerCamelCase   ,     lowerCamelCase   ,     use_reentrant=lowerCamelCase    )
																												__snake_case		:      str										=       sample.to(lowerCamelCase    )

																												# up
																												for up_block in self.up_blocks:
																																			__snake_case		:      str										=       torch.utils.checkpoint.checkpoint(
																																			    create_custom_forward(lowerCamelCase    )   ,     lowerCamelCase   ,     lowerCamelCase   ,     use_reentrant=lowerCamelCase    )
																					else:
																												# middle
																												__snake_case		:      List[str]										=       torch.utils.checkpoint.checkpoint(
																												    create_custom_forward(self.mid_block    )   ,     lowerCamelCase   ,     lowerCamelCase    )
																												__snake_case		:      Dict										=       sample.to(lowerCamelCase    )

																												# up
																												for up_block in self.up_blocks:
																																			__snake_case		:      Any										=       torch.utils.checkpoint.checkpoint(create_custom_forward(lowerCamelCase    )   ,     lowerCamelCase   ,     lowerCamelCase    )
														else:
																					# middle
																					__snake_case		:      List[Any]										=       self.mid_block(lowerCamelCase   ,     lowerCamelCase    )
																					__snake_case		:      Union[str, Any]										=       sample.to(lowerCamelCase    )

																					# up
																					for up_block in self.up_blocks:
																												__snake_case		:      Any										=       up_block(lowerCamelCase   ,     lowerCamelCase    )

        # post-process
														if latent_embeds is None:
																					__snake_case		:      str										=       self.conv_norm_out(lowerCamelCase    )
														else:
																					__snake_case		:      List[Any]										=       self.conv_norm_out(lowerCamelCase   ,     lowerCamelCase    )
														__snake_case		:      int										=       self.conv_act(lowerCamelCase    )
														__snake_case		:      str										=       self.conv_out(lowerCamelCase    )

														return sample

class     a		(nn.Module				):




							"""simple docstring"""


							def __init__(							self	:  Dict   ,     lowerCamelCase	:  str   ,     lowerCamelCase	:  List[str]   ,     lowerCamelCase	:  Optional[int]   ,     lowerCamelCase	:  Optional[Any]=None   ,     lowerCamelCase	:  int="random"   ,     lowerCamelCase	:  int=False   ,     lowerCamelCase	:  Optional[int]=True    )     ->   Dict:
														super().__init__()
														__snake_case		:      List[str]										=       n_e
														__snake_case		:      str										=       vq_embed_dim
														__snake_case		:      Optional[int]										=       beta
														__snake_case		:      List[str]										=       legacy

														__snake_case		:      str										=       nn.Embedding(self.n_e   ,     self.vq_embed_dim    )
														self.embedding.weight.data.uniform_(-1.0 / self.n_e   ,     1.0 / self.n_e    )

														__snake_case		:      Any										=       remap
														if self.remap is not None:
																					self.register_buffer("used"   ,     torch.tensor(np.load(self.remap    )    )    )
																					__snake_case		:      int										=       self.used.shape[0]
																					__snake_case		:      int										=       unknown_index  # "random" or "extra" or integer
																					if self.unknown_index == "extra":
																												__snake_case		:      Tuple										=       self.re_embed
																												__snake_case		:      Any										=       self.re_embed + 1
																					print(
																					    F'Remapping {self.n_e} indices to {self.re_embed} indices. '
																					    F'Using {self.unknown_index} for unknown indices.'    )
														else:
																					__snake_case		:      List[Any]										=       n_e

														__snake_case		:      Tuple										=       sane_index_shape

							def    __snake_case (							self	:  Dict   ,     lowerCamelCase	:  Optional[int]    )     ->   Optional[int]:
														__snake_case		:      List[Any]										=       inds.shape
														assert len(lowerCamelCase    ) > 1
														__snake_case		:      Union[str, Any]										=       inds.reshape(ishape[0]   ,     -1    )
														__snake_case		:      Optional[Any]										=       self.used.to(lowerCamelCase    )
														__snake_case		:      Tuple										=       (inds[:, :, None] == used[None, None, ...]).long()
														__snake_case		:      Optional[Any]										=       match.argmax(-1    )
														__snake_case		:      Dict										=       match.sum(2    ) < 1
														if self.unknown_index == "random":
																					__snake_case		:      Optional[int]										=       torch.randint(0   ,     self.re_embed   ,     size=new[unknown].shape    ).to(device=new.device    )
														else:
																					__snake_case		:      int										=       self.unknown_index
														return new.reshape(lowerCamelCase    )

							def    __snake_case (							self	:  Union[str, Any]   ,     lowerCamelCase	:  List[str]    )     ->   Any:
														__snake_case		:      int										=       inds.shape
														assert len(lowerCamelCase    ) > 1
														__snake_case		:      str										=       inds.reshape(ishape[0]   ,     -1    )
														__snake_case		:      Any										=       self.used.to(lowerCamelCase    )
														if self.re_embed > self.used.shape[0]:  # extra token
																					__snake_case		:      Optional[Any]										=       0  # simply set to zero
														__snake_case		:      List[str]										=       torch.gather(used[None, :][inds.shape[0] * [0], :]   ,     1   ,     lowerCamelCase    )
														return back.reshape(lowerCamelCase    )

							def    __snake_case (							self	:  int   ,     lowerCamelCase	:  int    )     ->   List[str]:
														# reshape z -> (batch, height, width, channel) and flatten
														__snake_case		:      Dict										=       z.permute(0   ,     2   ,     3   ,     1    ).contiguous()
														__snake_case		:      Tuple										=       z.view(-1   ,     self.vq_embed_dim    )

														# distances from z to embeddings e_j (z - e)^2 = z^2 + e^2 - 2 e * z
														__snake_case		:      List[Any]										=       torch.argmin(torch.cdist(lowerCamelCase   ,     self.embedding.weight    )   ,     dim=1    )

														__snake_case		:      Dict										=       self.embedding(lowerCamelCase    ).view(z.shape    )
														__snake_case		:      Dict										=       None
														__snake_case		:      str										=       None

														# compute loss for embedding
														if not self.legacy:
																					__snake_case		:      Tuple										=       self.beta * torch.mean((z_q.detach() - z) ** 2    ) + torch.mean((z_q - z.detach()) ** 2    )
														else:
																					__snake_case		:      List[Any]										=       torch.mean((z_q.detach() - z) ** 2    ) + self.beta * torch.mean((z_q - z.detach()) ** 2    )

														# preserve gradients
														__snake_case		:      Union[str, Any]										=       z + (z_q - z).detach()

														# reshape back to match original input shape
														__snake_case		:      List[str]										=       z_q.permute(0   ,     3   ,     1   ,     2    ).contiguous()

														if self.remap is not None:
																					__snake_case		:      Dict										=       min_encoding_indices.reshape(z.shape[0]   ,     -1    )  # add batch axis
																					__snake_case		:      Optional[int]										=       self.remap_to_used(lowerCamelCase    )
																					__snake_case		:      Any										=       min_encoding_indices.reshape(-1   ,     1    )  # flatten

														if self.sane_index_shape:
																					__snake_case		:      Optional[Any]										=       min_encoding_indices.reshape(z_q.shape[0]   ,     z_q.shape[2]   ,     z_q.shape[3]    )

														return z_q, loss, (perplexity, min_encodings, min_encoding_indices)






							def    __snake_case (							self	:  str   ,     lowerCamelCase	:  str   ,     lowerCamelCase	:  Dict    )     ->   int:
														# shape specifying (batch, height, width, channel)
														if self.remap is not None:
																					__snake_case		:      Optional[int]										=       indices.reshape(shape[0]   ,     -1    )  # add batch axis
																					__snake_case		:      Optional[int]										=       self.unmap_to_all(lowerCamelCase    )
																					__snake_case		:      int										=       indices.reshape(-1    )  # flatten again

														# get quantized latent vectors
														__snake_case		:      int										=       self.embedding(lowerCamelCase    )

														if shape is not None:
																					__snake_case		:      Any										=       z_q.view(lowerCamelCase    )
																					# reshape back to match original input shape
																					__snake_case		:      int										=       z_q.permute(0   ,     3   ,     1   ,     2    ).contiguous()

														return z_q

class     a		(_lowerCAmelCase				):




							"""simple docstring"""


							def __init__(							self	:  str   ,     lowerCamelCase	:  int   ,     lowerCamelCase	:  str=False    )     ->   Tuple:
														__snake_case		:      str										=       parameters
														__snake_case			,      __snake_case		:      int										=       torch.chunk(lowerCamelCase   ,     2   ,     dim=1    )
														__snake_case		:      Union[str, Any]										=       torch.clamp(self.logvar   ,     -30.0   ,     20.0    )
														__snake_case		:      Dict										=       deterministic
														__snake_case		:      Any										=       torch.exp(0.5 * self.logvar    )
														__snake_case		:      Tuple										=       torch.exp(self.logvar    )
														if self.deterministic:
																					__snake_case		:      Union[str, Any]										=       torch.zeros_like(
																					    self.mean   ,     device=self.parameters.device   ,     dtype=self.parameters.dtype    )

							def    __snake_case (							self	:  Dict   ,     lowerCamelCase	:  Optional[torch.Generator] = None    )     ->   torch.FloatTensor:
														# make sure sample is on the same device as the parameters and has same dtype
														__snake_case		:      str										=       randn_tensor(
														    self.mean.shape   ,     generator=lowerCamelCase   ,     device=self.parameters.device   ,     dtype=self.parameters.dtype    )
														__snake_case		:      Dict										=       self.mean + self.std * sample
														return x

							def    __snake_case (							self	:  str   ,     lowerCamelCase	:  Optional[Any]=None    )     ->   Optional[Any]:
														if self.deterministic:
																					return torch.Tensor([0.0]    )
														else:
																					if other is None:
																												return 0.5 * torch.sum(torch.pow(self.mean   ,     2    ) + self.var - 1.0 - self.logvar   ,     dim=[1, 2, 3]    )
																					else:
																												return 0.5 * torch.sum(
																												    torch.pow(self.mean - other.mean   ,     2    ) / other.var
																												    + self.var / other.var
																												    - 1.0
																												    - self.logvar
																												    + other.logvar   ,     dim=[1, 2, 3]   ,     )

							def    __snake_case (							self	:  int   ,     lowerCamelCase	:  Any   ,     lowerCamelCase	:  List[Any]=[1, 2, 3]    )     ->   str:
														if self.deterministic:
																					return torch.Tensor([0.0]    )
														__snake_case		:      int										=       np.log(2.0 * np.pi    )
														return 0.5 * torch.sum(logtwopi + self.logvar + torch.pow(sample - self.mean   ,     2    ) / self.var   ,     dim=lowerCamelCase    )






							def    __snake_case (							self	:  Tuple    )     ->   List[str]:
														return self.mean





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   :							List[str]					  =  ["image_processor", "tokenizer"]
							__UpperCAmelCase   :							str					  =  "OwlViTImageProcessor"
							__UpperCAmelCase   :							Dict					  =  ("CLIPTokenizer", "CLIPTokenizerFast")

							def __init__(							self	:  str   ,     lowerCamelCase	:  Any=None   ,     lowerCamelCase	:  Any=None   ,     **lowerCamelCase	:  Union[str, Any]    )     ->   List[Any]:
														__snake_case		:      List[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."   ,     lowerCamelCase   ,     )
																					__snake_case		:      List[Any]										=       kwargs.pop("feature_extractor"    )

														__snake_case		:      str										=       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	:  Union[str, Any]   ,     lowerCamelCase	:  Tuple=None   ,     lowerCamelCase	:  int=None   ,     lowerCamelCase	:  Union[str, Any]=None   ,     lowerCamelCase	:  List[str]="max_length"   ,     lowerCamelCase	:  Dict="np"   ,     **lowerCamelCase	:  str    )     ->   List[Any]:

														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    )):
																												__snake_case		:      Union[str, Any]										=       [self.tokenizer(lowerCamelCase   ,     padding=lowerCamelCase   ,     return_tensors=lowerCamelCase   ,     **lowerCamelCase    )]

																					elif isinstance(lowerCamelCase   ,     lowerCamelCase    ) and isinstance(text[0]   ,     lowerCamelCase    ):
																												__snake_case		:      Tuple										=       []

																												# Maximum number of queries across batch
																												__snake_case		:      str										=       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:
																																										__snake_case		:      Dict										=       t + [" "] * (max_num_queries - len(lowerCamelCase    ))

																																			__snake_case		:      int										=       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":
																												__snake_case		:      Any										=       np.concatenate([encoding["input_ids"] for encoding in encodings]   ,     axis=0    )
																												__snake_case		:      Tuple										=       np.concatenate([encoding["attention_mask"] for encoding in encodings]   ,     axis=0    )

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

																												__snake_case		:      List[Any]										=       jnp.concatenate([encoding["input_ids"] for encoding in encodings]   ,     axis=0    )
																												__snake_case		:      Any										=       jnp.concatenate([encoding["attention_mask"] for encoding in encodings]   ,     axis=0    )

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

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

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

																												__snake_case		:      int										=       tf.stack([encoding["input_ids"] for encoding in encodings]   ,     axis=0    )
																												__snake_case		:      Dict										=       tf.stack([encoding["attention_mask"] for encoding in encodings]   ,     axis=0    )

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

																					__snake_case		:      Any										=       BatchEncoding()
																					__snake_case		:      Tuple										=       input_ids
																					__snake_case		:      int										=       attention_mask

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

														if images is not None:
																					__snake_case		:      Optional[int]										=       self.image_processor(lowerCamelCase   ,     return_tensors=lowerCamelCase   ,     **lowerCamelCase    )

														if text is not None and images is not None:
																					__snake_case		:      List[str]										=       image_features.pixel_values
																					return encoding
														elif query_images is not None and images is not None:
																					__snake_case		:      int										=       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    __snake_case (							self	:  Dict   ,     *lowerCamelCase	:  List[Any]   ,     **lowerCamelCase	:  Union[str, Any]    )     ->   str:
														return self.image_processor.post_process(*lowerCamelCase   ,     **lowerCamelCase    )

							def    __snake_case (							self	:  Union[str, Any]   ,     *lowerCamelCase	:  str   ,     **lowerCamelCase	:  List[str]    )     ->   Tuple:
														return self.image_processor.post_process_object_detection(*lowerCamelCase   ,     **lowerCamelCase    )

							def    __snake_case (							self	:  Optional[Any]   ,     *lowerCamelCase	:  Optional[Any]   ,     **lowerCamelCase	:  Optional[Any]    )     ->   Any:
														return self.image_processor.post_process_image_guided_detection(*lowerCamelCase   ,     **lowerCamelCase    )

							def    __snake_case (							self	:  List[Any]   ,     *lowerCamelCase	:  Tuple   ,     **lowerCamelCase	:  Optional[int]    )     ->   str:
														return self.tokenizer.batch_decode(*lowerCamelCase   ,     **lowerCamelCase    )

							def    __snake_case (							self	:  Union[str, Any]   ,     *lowerCamelCase	:  Tuple   ,     **lowerCamelCase	:  List[Any]    )     ->   Tuple:
														return self.tokenizer.decode(*lowerCamelCase   ,     **lowerCamelCase    )

							@property
							def    __snake_case (							self	:  Any    )     ->   Dict:
														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    __snake_case (							self	:  List[str]    )     ->   Union[str, Any]:
														warnings.warn(
														    "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."   ,     lowerCamelCase   ,     )
														return self.image_processor

