
'''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				(							__snake_case						):
     __magic_name__						=		['''image_processor''', '''tokenizer''']
     __magic_name__						=		'''OwlViTImageProcessor'''
     __magic_name__						=		('''CLIPTokenizer''', '''CLIPTokenizerFast''')





     def __init__(							self						,			SCREAMING_SNAKE_CASE=None						,			SCREAMING_SNAKE_CASE=None						,			**SCREAMING_SNAKE_CASE	) ->				Optional[int]:






         """simple docstring"""






         A       :   Optional[int]					=						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						,			)
             A       :   Optional[int]					=						kwargs.pop('''feature_extractor'''	)

         A       :   Tuple					=						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	) ->				List[str]:






         """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	)):
                 A       :   List[Any]					=						[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	):
                 A       :   str					=						[]

                 # Maximum number of queries across batch
                 A       :   List[Any]					=						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:
                         A       :   Dict					=						t + [''' '''] * (max_num_queries - len(SCREAMING_SNAKE_CASE	))

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

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

                 A       :   str					=						jnp.concatenate([encoding['''input_ids'''] for encoding in encodings]						,			axis=0	)
                 A       :   Optional[int]					=						jnp.concatenate([encoding['''attention_mask'''] for encoding in encodings]						,			axis=0	)

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

                 A       :   Any					=						torch.cat([encoding['''input_ids'''] for encoding in encodings]						,			dim=0	)
                 A       :   Optional[Any]					=						torch.cat([encoding['''attention_mask'''] for encoding in encodings]						,			dim=0	)

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

                 A       :   Tuple					=						tf.stack([encoding['''input_ids'''] for encoding in encodings]						,			axis=0	)
                 A       :   Optional[Any]					=						tf.stack([encoding['''attention_mask'''] for encoding in encodings]						,			axis=0	)

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

             A       :   List[Any]					=						BatchEncoding()
             A       :   Optional[int]					=						input_ids
             A       :   int					=						attention_mask

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

         if images is not None:
             A       :   Union[str, 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:
             A       :   Dict					=						image_features.pixel_values
             return encoding
         elif query_images is not None and images is not None:
             A       :   Tuple					=						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 				__lowerCAmelCase							(							self						,			*SCREAMING_SNAKE_CASE						,			**SCREAMING_SNAKE_CASE	) ->				Optional[int]:






         """simple docstring"""






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





     def 				__lowerCAmelCase							(							self						,			*SCREAMING_SNAKE_CASE						,			**SCREAMING_SNAKE_CASE	) ->				Tuple:






         """simple docstring"""






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





     def 				__lowerCAmelCase							(							self						,			*SCREAMING_SNAKE_CASE						,			**SCREAMING_SNAKE_CASE	) ->				Optional[int]:






         """simple docstring"""






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





     def 				__lowerCAmelCase							(							self						,			*SCREAMING_SNAKE_CASE						,			**SCREAMING_SNAKE_CASE	) ->				str:






         """simple docstring"""






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





     def 				__lowerCAmelCase							(							self						,			*SCREAMING_SNAKE_CASE						,			**SCREAMING_SNAKE_CASE	) ->				Optional[int]:






         """simple docstring"""






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





     @property
     def 				__lowerCAmelCase							(							self	) ->				Optional[int]:






         """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 				__lowerCAmelCase							(							self	) ->				Union[str, Any]:






         """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'''




from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import PIL

from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available
from .timesteps import (
    fastaa_timesteps,
    smartaa_timesteps,
    smartaa_timesteps,
    smartaaa_timesteps,
    smartaaa_timesteps,
    superaa_timesteps,
    superaa_timesteps,
    superaaa_timesteps,
)





@dataclass
class  A				(							__snake_case						):
     __magic_name__						=		42
     __magic_name__						=		42
     __magic_name__						=		42


try:
      if not (is_transformers_available() and is_torch_available()):
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
      from .pipeline_if import IFPipeline
      from .pipeline_if_imgaimg import IFImgaImgPipeline
      from .pipeline_if_imgaimg_superresolution import IFImgaImgSuperResolutionPipeline
      from .pipeline_if_inpainting import IFInpaintingPipeline
      from .pipeline_if_inpainting_superresolution import IFInpaintingSuperResolutionPipeline
      from .pipeline_if_superresolution import IFSuperResolutionPipeline
      from .safety_checker import IFSafetyChecker
      from .watermark import IFWatermarker




