



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       UpperCAmelCase__(							unittest.TestCase	):

   '''simple docstring'''




   @slow
   def 			UpperCAmelCase		(						self  :			Optional[Any])	->				List[str]:




         """simple docstring"""

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

         from datasets import load_dataset

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

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

         lowercase__     =  image_processor(UpperCamelCase_			,				return_tensors='pt').to(UpperCamelCase_)

         # forward pass
         with torch.no_grad():
               lowercase__     =  model(**UpperCamelCase_)
               lowercase__     =  outputs.logits

         lowercase__     =  torch.Size((1, 16))
         self.assertEqual(logits.shape			,				UpperCamelCase_)

         lowercase__     =  torch.tensor(
             [-0.41_58, -0.40_92, -0.43_47]			,				device=UpperCamelCase_			,				dtype=torch.float			,				)
         self.assertTrue(torch.allclose(logits[0, :3]			,				UpperCamelCase_			,				atol=1E-4))





from __future__ import annotations

def   _lowerCAmelCase   (						A__						,  A__	):
      if b == 0:
            return (1, 0)
      ((lowercase__),	(lowercase__))     =  extended_euclid(A__						,  a % b	)
      lowercase__     =  a // b
      return (y, x - k * y)

def   _lowerCAmelCase   (						A__						,  A__						,  A__						,  A__	):
      ((lowercase__),	(lowercase__))     =  extended_euclid(A__						,  A__	)
      lowercase__     =  na * na
      lowercase__     =  ra * x * na + ra * y * na
      return (n % m + m) % m

def   _lowerCAmelCase   (						A__						,  A__	):
      ((lowercase__),	(lowercase__))     =  extended_euclid(A__						,  A__	)
      if b < 0:
            lowercase__     =  (b % n + n) % n
      return b

def   _lowerCAmelCase   (						A__						,  A__						,  A__						,  A__	):
      lowercase__,	lowercase__     =  invert_modulo(A__						,  A__	), invert_modulo(A__						,  A__	)
      lowercase__     =  na * na
      lowercase__     =  ra * x * na + ra * y * na
      return (n % m + m) % m


if __name__ == "__main__":
       from doctest import testmod

       testmod(name="chinese_remainder_theorem", verbose=True)
       testmod(name="chinese_remainder_theorem2", verbose=True)
       testmod(name="invert_modulo", verbose=True)
       testmod(name="extended_euclid", verbose=True)
