





from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


__lowerCamelCase :  Optional[int]										=  logging.get_logger(__name__)

__lowerCamelCase :  Any										=  {
    """facebook/convnextv2-tiny-1k-224""": """https://huggingface.co/facebook/convnextv2-tiny-1k-224/resolve/main/config.json""",
}



class       A__     ( __snake_case ,     __snake_case    ):
      _UpperCAmelCase			:int							=     'convnextv2'





      def __init__(				self ,							A_=3 ,							A_=4 ,							A_=4 ,							A_=None ,							A_=None ,							A_="gelu" ,							A_=0.02 ,							A_=1e-12 ,							A_=0.0 ,							A_=224 ,							A_=None ,							A_=None ,							**A_ ,							):
       '''simple docstring'''




       super().__init__(**A_     )

       UpperCamelCase			:      List[str] 			=     num_channels
       UpperCamelCase			:      Tuple 			=     patch_size
       UpperCamelCase			:      Union[str, Any] 			=     num_stages
       UpperCamelCase			:      List[Any] 			=     [96, 192, 384, 768] if hidden_sizes is None else hidden_sizes
       UpperCamelCase			:      Optional[Any] 			=     [3, 3, 9, 3] if depths is None else depths
       UpperCamelCase			:      Optional[int] 			=     hidden_act
       UpperCamelCase			:      Dict 			=     initializer_range
       UpperCamelCase			:      Optional[Any] 			=     layer_norm_eps
       UpperCamelCase			:      str 			=     drop_path_rate
       UpperCamelCase			:      Optional[int] 			=     image_size
       UpperCamelCase			:      List[str] 			=     ["stem"] + [F"""stage{idx}""" for idx in range(1 ,							len(self.depths     ) + 1     )]
       UpperCamelCase			,					UpperCamelCase			:      Union[str, Any] 			=     get_aligned_output_features_output_indices(
           out_features=A_ ,							out_indices=A_ ,							stage_names=self.stage_names     )







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__     ( __snake_case    ):
      _UpperCAmelCase			:Optional[int]							=     ['image_processor', 'tokenizer']
      _UpperCAmelCase			:Tuple							=     'BlipImageProcessor'
      _UpperCAmelCase			:Optional[int]							=     'AutoTokenizer'





      def __init__(				self ,							A_ ,							A_     ):
       '''simple docstring'''




       UpperCamelCase			:      str 			=     False
       super().__init__(A_ ,							A_     )
       UpperCamelCase			:      str 			=     self.image_processor





      def __call__(				self ,							A_ = None ,							A_ = None ,							A_ = True ,							A_ = False ,							A_ = None ,							A_ = None ,							A_ = 0 ,							A_ = None ,							A_ = None ,							A_ = False ,							A_ = False ,							A_ = False ,							A_ = False ,							A_ = False ,							A_ = True ,							A_ = None ,							**A_ ,							):
       '''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:
        UpperCamelCase			:      int 			=     self.tokenizer
        UpperCamelCase			:      Optional[int] 			=     self.tokenizer(
            text=A_ ,							add_special_tokens=A_ ,							padding=A_ ,							truncation=A_ ,							max_length=A_ ,							stride=A_ ,							pad_to_multiple_of=A_ ,							return_attention_mask=A_ ,							return_overflowing_tokens=A_ ,							return_special_tokens_mask=A_ ,							return_offsets_mapping=A_ ,							return_token_type_ids=A_ ,							return_length=A_ ,							verbose=A_ ,							return_tensors=A_ ,							**A_ ,							)
        return text_encoding

       # add pixel_values
       UpperCamelCase			:      int 			=     self.image_processor(A_ ,							return_tensors=A_     )

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

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

       return encoding_image_processor





      def  __UpperCamelCase(				self ,							*A_ ,							**A_     ):
       '''simple docstring'''




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





      def  __UpperCamelCase(				self ,							*A_ ,							**A_     ):
       '''simple docstring'''




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





      @property
      # Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
      def  __UpperCamelCase(				self     ):
       '''simple docstring'''




       UpperCamelCase			:      List[str] 			=     self.tokenizer.model_input_names
       UpperCamelCase			:      int 			=     self.image_processor.model_input_names
       return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names     )     )
