
"""simple docstring"""

import os
from typing import List, Optional, Union

from ...image_processing_utils import BatchFeature
from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType
from ..auto import AutoTokenizer

class __lowerCAmelCase	(   __a    ):
     lowercase		     =		['''image_processor''', '''tokenizer''']
     lowercase		     =		'''BlipImageProcessor'''
     lowercase		     =		'''AutoTokenizer'''





     def __init__(			self			,  __UpperCAmelCase			,  __UpperCAmelCase			,  __UpperCAmelCase   ):

      '''simple docstring'''




      super().__init__(snake_case__			,  snake_case__   )

      # add QFormer tokenizer
      __UpperCamelCase       						= qformer_tokenizer





     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			,  ):

      '''simple docstring'''




      if images is None and text is None:
       raise ValueError('You have to specify at least images or text.'   )

      __UpperCamelCase       						= BatchFeature()

      if text is not None:
       __UpperCamelCase       						= self.tokenizer(
           text=snake_case__			,  add_special_tokens=snake_case__			,  padding=snake_case__			,  truncation=snake_case__			,  max_length=snake_case__			,  stride=snake_case__			,  pad_to_multiple_of=snake_case__			,  return_attention_mask=snake_case__			,  return_overflowing_tokens=snake_case__			,  return_special_tokens_mask=snake_case__			,  return_offsets_mapping=snake_case__			,  return_token_type_ids=snake_case__			,  return_length=snake_case__			,  verbose=snake_case__			,  return_tensors=snake_case__			,  **snake_case__			,  )
       encoding.update(snake_case__   )
       __UpperCamelCase       						= self.qformer_tokenizer(
           text=snake_case__			,  add_special_tokens=snake_case__			,  padding=snake_case__			,  truncation=snake_case__			,  max_length=snake_case__			,  stride=snake_case__			,  pad_to_multiple_of=snake_case__			,  return_attention_mask=snake_case__			,  return_overflowing_tokens=snake_case__			,  return_special_tokens_mask=snake_case__			,  return_offsets_mapping=snake_case__			,  return_token_type_ids=snake_case__			,  return_length=snake_case__			,  verbose=snake_case__			,  return_tensors=snake_case__			,  **snake_case__			,  )
       __UpperCamelCase       						= qformer_text_encoding.pop('input_ids'   )
       __UpperCamelCase       						= qformer_text_encoding.pop('attention_mask'   )

      if images is not None:
       __UpperCamelCase       						= self.image_processor(snake_case__			,  return_tensors=snake_case__   )
       encoding.update(snake_case__   )

      return encoding





     def 		UpperCAmelCase      (			self			,  *__UpperCAmelCase			,  **__UpperCAmelCase   ):

      '''simple docstring'''




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





     def 		UpperCAmelCase      (			self			,  *__UpperCAmelCase			,  **__UpperCAmelCase   ):

      '''simple docstring'''




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





     @property
     # Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      __UpperCamelCase       						= self.tokenizer.model_input_names
      __UpperCamelCase       						= self.image_processor.model_input_names
      return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names   )   )





     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase			,  **__UpperCAmelCase   ):

      '''simple docstring'''




      if os.path.isfile(snake_case__   ):
       raise ValueError(F'Provided path ({save_directory}) should be a directory, not a file'   )
      os.makedirs(snake_case__			,  exist_ok=snake_case__   )
      __UpperCamelCase       						= os.path.join(snake_case__			,  'qformer_tokenizer'   )
      self.qformer_tokenizer.save_pretrained(snake_case__   )
      return super().save_pretrained(snake_case__			,  **snake_case__   )







     @classmethod
     def 		UpperCAmelCase      (			cls			,  __UpperCAmelCase			,  **__UpperCAmelCase   ):

      '''simple docstring'''




      __UpperCamelCase       						= AutoTokenizer.from_pretrained(snake_case__			,  subfolder='qformer_tokenizer'   )
      __UpperCamelCase       						= cls._get_arguments_from_pretrained(snake_case__			,  **snake_case__   )
      args.append(snake_case__   )
      return cls(*snake_case__   )





"""simple docstring"""

def 							A		(       snake_case   :int       ,      snake_case   :int	)   ->			int:
 return int(input_a == input_a == 0	)






def 							A		(       )   ->			None:
 print('Truth Table of NOR Gate:'	)
 print('|   Input 1   |  Input 2  | Output |'	)
 print(f'|      0      |    0      |  {nor_gate(0       ,      0	)}     |'	)
 print(f'|      0      |    1      |  {nor_gate(0       ,      1	)}     |'	)
 print(f'|      1      |    0      |  {nor_gate(1       ,      0	)}     |'	)
 print(f'|      1      |    1      |  {nor_gate(1       ,      1	)}     |'	)


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      main()



