
"""simple docstring"""

from queue import Queue
from typing import TYPE_CHECKING, Optional


if TYPE_CHECKING:
   from ..models.auto import AutoTokenizer

class __lowerCAmelCase	:





     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase   ):

      '''simple docstring'''




      raise NotImplementedError()







     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      raise NotImplementedError()


class __lowerCAmelCase	(   __SCREAMING_SNAKE_CASE    ):





     def __init__(			self			,  __UpperCAmelCase			,  __UpperCAmelCase = False			,  **__UpperCAmelCase   ):

      '''simple docstring'''




      __UpperCamelCase       						= tokenizer
      __UpperCamelCase       						= skip_prompt
      __UpperCamelCase       						= decode_kwargs

      # variables used in the streaming process
      __UpperCamelCase       						= []
      __UpperCamelCase       						= 0
      __UpperCamelCase       						= True





     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase   ):

      '''simple docstring'''




      if len(value.shape   ) > 1 and value.shape[0] > 1:
       raise ValueError('TextStreamer only supports batch size 1'   )
      elif len(value.shape   ) > 1:
       __UpperCamelCase       						= value[0]

      if self.skip_prompt and self.next_tokens_are_prompt:
       __UpperCamelCase       						= False
       return

      # Add the new token to the cache and decodes the entire thing.
      self.token_cache.extend(value.tolist()   )
      __UpperCamelCase       						= self.tokenizer.decode(self.token_cache			,  **self.decode_kwargs   )

      # After the symbol for a new line, we flush the cache.
      if text.endswith('\n'   ):
       __UpperCamelCase       						= text[self.print_len :]
       __UpperCamelCase       						= []
       __UpperCamelCase       						= 0
      # If the last token is a CJK character, we print the characters.
      elif len(__UpperCAmelCase   ) > 0 and self._is_chinese_char(ord(text[-1]   )   ):
       __UpperCamelCase       						= text[self.print_len :]
       self.print_len += len(__UpperCAmelCase   )
      # Otherwise, prints until the last space char (simple heuristic to avoid printing incomplete words,
      # which may change with the subsequent token -- there are probably smarter ways to do this!)
      else:
       __UpperCamelCase       						= text[self.print_len : text.rfind(' '   ) + 1]
       self.print_len += len(__UpperCAmelCase   )

      self.on_finalized_text(__UpperCAmelCase   )





     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      if len(self.token_cache   ) > 0:
       __UpperCamelCase       						= self.tokenizer.decode(self.token_cache			,  **self.decode_kwargs   )
       __UpperCamelCase       						= text[self.print_len :]
       __UpperCamelCase       						= []
       __UpperCamelCase       						= 0
      else:
       __UpperCamelCase       						= ''

      __UpperCamelCase       						= True
      self.on_finalized_text(__UpperCAmelCase			,  stream_end=__UpperCAmelCase   )





     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase			,  __UpperCAmelCase = False   ):

      '''simple docstring'''




      print(__UpperCAmelCase			,  flush=__UpperCAmelCase			,  end='' if not stream_end else None   )







     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase   ):

      '''simple docstring'''




      if (
          (cp >= 0x4e_00 and cp <= 0x9f_ff)
          or (cp >= 0x34_00 and cp <= 0x4d_bf)  #
          or (cp >= 0x2_00_00 and cp <= 0x2_a6_df)  #
          or (cp >= 0x2_a7_00 and cp <= 0x2_b7_3f)  #
          or (cp >= 0x2_b7_40 and cp <= 0x2_b8_1f)  #
          or (cp >= 0x2_b8_20 and cp <= 0x2_ce_af)  #
          or (cp >= 0xf9_00 and cp <= 0xfa_ff)
          or (cp >= 0x2_f8_00 and cp <= 0x2_fa_1f)  #
      ):  #
       return True

      return False


class __lowerCAmelCase	(   __SCREAMING_SNAKE_CASE    ):





     def __init__(			self			,  __UpperCAmelCase			,  __UpperCAmelCase = False			,  __UpperCAmelCase = None			,  **__UpperCAmelCase   ):

      '''simple docstring'''




      super().__init__(__UpperCAmelCase			,  __UpperCAmelCase			,  **__UpperCAmelCase   )
      __UpperCamelCase       						= Queue()
      __UpperCamelCase       						= None
      __UpperCamelCase       						= timeout





     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase			,  __UpperCAmelCase = False   ):

      '''simple docstring'''




      self.text_queue.put(__UpperCAmelCase			,  timeout=self.timeout   )
      if stream_end:
       self.text_queue.put(self.stop_signal			,  timeout=self.timeout   )





     def __iter__(			self   ):

      '''simple docstring'''




      return self







     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      __UpperCamelCase       						= self.text_queue.get(timeout=self.timeout   )
      if value == self.stop_signal:
       raise StopIteration()
      else:
       return value





"""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()



