
"""simple docstring"""

import unittest

from transformers import is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision, slow, torch_device


if is_torch_available():
   import torch

   from transformers import AutoModelForImageClassification

if is_vision_available():
   from transformers import AutoImageProcessor

@require_torch
@require_vision
class __lowerCAmelCase	(   unittest.TestCase    ):





     @slow
     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      __UpperCamelCase       						= AutoImageProcessor.from_pretrained('microsoft/dit-base-finetuned-rvlcdip'   )
      __UpperCamelCase       						= AutoModelForImageClassification.from_pretrained('microsoft/dit-base-finetuned-rvlcdip'   )
      model.to(UpperCAmelCase_   )

      from datasets import load_dataset

      __UpperCamelCase       						= load_dataset('nielsr/rvlcdip-demo'   )

      __UpperCamelCase       						= dataset['train'][0]['image'].convert('RGB'   )

      __UpperCamelCase       						= image_processor(UpperCAmelCase_			,  return_tensors='pt'   ).to(UpperCAmelCase_   )

      # forward pass
      with torch.no_grad():
       __UpperCamelCase       						= model(**UpperCAmelCase_   )
       __UpperCamelCase       						= outputs.logits

      __UpperCamelCase       						= torch.Size((1, 16)   )
      self.assertEqual(logits.shape			,  UpperCAmelCase_   )

      __UpperCamelCase       						= torch.tensor(
          [-0.4_1_5_8, -0.4_0_9_2, -0.4_3_4_7]			,  device=UpperCAmelCase_			,  dtype=torch.float			,  )
      self.assertTrue(torch.allclose(logits[0, :3]			,  UpperCAmelCase_			,  atol=1E-4   )   )





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



