






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 				_UpperCamelCase      (__a      ):
      snake_case_	=				["""image_processor""", """tokenizer"""]
      snake_case_	=				"""BlipImageProcessor"""
      snake_case_	=				"""AutoTokenizer"""


      def __init__(						self       ,    __UpperCamelCase       ,    __UpperCamelCase						)->						Optional[int]:
           __lowerCAmelCase             =       False
           super().__init__(_UpperCamelCase       ,    _UpperCamelCase						)
           __lowerCAmelCase             =       self.image_processor


      def __call__(						self       ,    __UpperCamelCase = None       ,    __UpperCamelCase = None       ,    __UpperCamelCase = True       ,    __UpperCamelCase = False       ,    __UpperCamelCase = None       ,    __UpperCamelCase = None       ,    __UpperCamelCase = 0       ,    __UpperCamelCase = None       ,    __UpperCamelCase = None       ,    __UpperCamelCase = False       ,    __UpperCamelCase = False       ,    __UpperCamelCase = False       ,    __UpperCamelCase = False       ,    __UpperCamelCase = False       ,    __UpperCamelCase = True       ,    __UpperCamelCase = None       ,    **__UpperCamelCase       ,    )->						BatchEncoding:
           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:
                __lowerCAmelCase             =       self.tokenizer
                __lowerCAmelCase             =       self.tokenizer(
                    text=_UpperCamelCase       ,    add_special_tokens=_UpperCamelCase       ,    padding=_UpperCamelCase       ,    truncation=_UpperCamelCase       ,    max_length=_UpperCamelCase       ,    stride=_UpperCamelCase       ,    pad_to_multiple_of=_UpperCamelCase       ,    return_attention_mask=_UpperCamelCase       ,    return_overflowing_tokens=_UpperCamelCase       ,    return_special_tokens_mask=_UpperCamelCase       ,    return_offsets_mapping=_UpperCamelCase       ,    return_token_type_ids=_UpperCamelCase       ,    return_length=_UpperCamelCase       ,    verbose=_UpperCamelCase       ,    return_tensors=_UpperCamelCase       ,    **_UpperCamelCase       ,    )
                return text_encoding

           # add pixel_values
           __lowerCAmelCase             =       self.image_processor(_UpperCamelCase       ,    return_tensors=_UpperCamelCase						)

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

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

           return encoding_image_processor


      def 			__UpperCAmelCase		(						self       ,    *__UpperCamelCase       ,    **__UpperCamelCase						)->						Any:
           return self.tokenizer.batch_decode(*_UpperCamelCase       ,    **_UpperCamelCase						)


      def 			__UpperCAmelCase		(						self       ,    *__UpperCamelCase       ,    **__UpperCamelCase						)->						Any:
           return self.tokenizer.decode(*_UpperCamelCase       ,    **_UpperCamelCase						)


      @property
      # Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
      def 			__UpperCAmelCase		(						self						)->						Dict:
           __lowerCAmelCase             =       self.tokenizer.model_input_names
           __lowerCAmelCase             =       self.image_processor.model_input_names
           return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names						)						)








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

import numpy as np
import PIL
from PIL import Image

from ...utils import BaseOutput, is_torch_available, is_transformers_available





@dataclass
class       _lowerCAmelCase   (      __a			):
				_lowercase     						=42
				_lowercase     						=42


if is_transformers_available() and is_torch_available():
			from .pipeline_semantic_stable_diffusion import SemanticStableDiffusionPipeline



