

'''simple docstring'''
import re
import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin


class        a__  (							lowerCamelCase_  ):
   _SCREAMING_SNAKE_CASE   :					Optional[Any]     	=							['image_processor', 'tokenizer']
   _SCREAMING_SNAKE_CASE   :					List[Any]     	=							'AutoImageProcessor'
   _SCREAMING_SNAKE_CASE   :					List[Any]     	=							'AutoTokenizer'


   def __init__(			self      ,    _UpperCamelCase=None      ,    _UpperCamelCase=None      ,    **_UpperCamelCase  ):





      """simple docstring"""





      _lowercase      :				Optional[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."      ,    _UpperCamelCase      ,    )
         _lowercase      :				int      					=       kwargs.pop("feature_extractor"  )

      _lowercase      :				Optional[int]      					=       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__(_UpperCamelCase      ,    _UpperCamelCase  )
      _lowercase      :				Optional[Any]      					=       self.image_processor
      _lowercase      :				Union[str, Any]      					=       False


   def __call__(			self      ,    *_UpperCamelCase      ,    **_UpperCamelCase  ):





      """simple docstring"""





      if self._in_target_context_manager:
         return self.current_processor(*_UpperCamelCase      ,    **_UpperCamelCase  )

      _lowercase      :				Union[str, Any]      					=       kwargs.pop("images"      ,    _UpperCamelCase  )
      _lowercase      :				Dict      					=       kwargs.pop("text"      ,    _UpperCamelCase  )
      if len(_UpperCamelCase  ) > 0:
         _lowercase      :				int      					=       args[0]
         _lowercase      :				List[Any]      					=       args[1:]

      if images is None and text is None:
         raise ValueError("You need to specify either an `images` or `text` input to process."  )

      if images is not None:
         _lowercase      :				Any      					=       self.image_processor(_UpperCamelCase      ,    *_UpperCamelCase      ,    **_UpperCamelCase  )
      if text is not None:
         _lowercase      :				Optional[Any]      					=       self.tokenizer(_UpperCamelCase      ,    **_UpperCamelCase  )

      if text is None:
         return inputs
      elif images is None:
         return encodings
      else:
         _lowercase      :				Tuple      					=       encodings["input_ids"]
         return inputs


   def 						_lowerCamelCase       (			self      ,    *_UpperCamelCase      ,    **_UpperCamelCase  ):





      """simple docstring"""





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


   def 						_lowerCamelCase       (			self      ,    *_UpperCamelCase      ,    **_UpperCamelCase  ):





      """simple docstring"""





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


   @contextmanager
   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      warnings.warn(
          "`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your "
          "labels by using the argument `text` of the regular `__call__` method (either in the same call as "
          "your images inputs, or in a separate call."  )
      _lowercase      :				List[Any]      					=       True
      _lowercase      :				Tuple      					=       self.tokenizer
      yield
      _lowercase      :				Optional[Any]      					=       self.image_processor
      _lowercase      :				Tuple      					=       False


   def 						_lowerCamelCase       (			self      ,    _UpperCamelCase      ,    _UpperCamelCase=False      ,    _UpperCamelCase=None  ):





      """simple docstring"""





      if added_vocab is None:
         _lowercase      :				Any      					=       self.tokenizer.get_added_vocab()

      _lowercase      :				List[str]      					=       {}

      while tokens:
         _lowercase      :				Any      					=       re.search(R"<s_(.*?)>"      ,    _UpperCamelCase      ,    re.IGNORECASE  )
         if start_token is None:
            break
         _lowercase      :				Any      					=       start_token.group(1  )
         _lowercase      :				str      					=       re.search(Rf'''</s_{key}>'''      ,    _UpperCamelCase      ,    re.IGNORECASE  )
         _lowercase      :				Dict      					=       start_token.group()
         if end_token is None:
            _lowercase      :				List[Any]      					=       tokens.replace(_UpperCamelCase      ,    ""  )
         else:
            _lowercase      :				List[Any]      					=       end_token.group()
            _lowercase      :				Any      					=       re.escape(_UpperCamelCase  )
            _lowercase      :				Tuple      					=       re.escape(_UpperCamelCase  )
            _lowercase      :				Dict      					=       re.search(f'''{start_token_escaped}(.*?){end_token_escaped}'''      ,    _UpperCamelCase      ,    re.IGNORECASE  )
            if content is not None:
               _lowercase      :				Optional[int]      					=       content.group(1  ).strip()
               if r"<s_" in content and r"</s_" in content:  # non-leaf node
                  _lowercase      :				Optional[int]      					=       self.tokenajson(_UpperCamelCase      ,    is_inner_value=_UpperCamelCase      ,    added_vocab=_UpperCamelCase  )
                  if value:
                     if len(_UpperCamelCase  ) == 1:
                        _lowercase      :				Union[str, Any]      					=       value[0]
                     _lowercase      :				Optional[int]      					=       value
               else:  # leaf nodes
                  _lowercase      :				Optional[int]      					=       []
                  for leaf in content.split(R"<sep/>"  ):
                     _lowercase      :				Optional[int]      					=       leaf.strip()
                     if leaf in added_vocab and leaf[0] == "<" and leaf[-2:] == "/>":
                        _lowercase      :				List[Any]      					=       leaf[1:-2]  # for categorical special tokens
                     output[key].append(_UpperCamelCase  )
                  if len(output[key]  ) == 1:
                     _lowercase      :				Optional[int]      					=       output[key][0]

            _lowercase      :				Optional[Any]      					=       tokens[tokens.find(_UpperCamelCase  ) + len(_UpperCamelCase  ) :].strip()
            if tokens[:6] == r"<sep/>":  # non-leaf nodes
               return [output] + self.tokenajson(tokens[6:]      ,    is_inner_value=_UpperCamelCase      ,    added_vocab=_UpperCamelCase  )

      if len(_UpperCamelCase  ):
         return [output] if is_inner_value else output
      else:
         return [] if is_inner_value else {"text_sequence": tokens}


   @property
   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      warnings.warn(
          "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."      ,    _UpperCamelCase      ,    )
      return self.image_processor_class






   @property
   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      warnings.warn(
          "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."      ,    _UpperCamelCase      ,    )
      return self.image_processor









'''simple docstring'''
def  _A		(     snake_case		,							snake_case					)      ->     int:
   return int((input_a, input_a).count(0					) != 0					)







def  _A		(     )      ->     None:
   assert nand_gate(0		,							0					) == 1
   assert nand_gate(0		,							1					) == 1
   assert nand_gate(1		,							0					) == 1
   assert nand_gate(1		,							1					) == 0


if __name__ == "__main__":
    print(nand_gate(0, 0))
    print(nand_gate(0, 1))
    print(nand_gate(1, 0))
    print(nand_gate(1, 1))






