


"""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 				_SCREAMING_SNAKE_CASE				(							unittest.TestCase  ):
   """simple docstring"""



   @slow
   def 					UpperCAmelCase__(						self						)      ->							List[str]:
    lowercase__       :       Optional[Any]				=						AutoImageProcessor.from_pretrained("""microsoft/dit-base-finetuned-rvlcdip"""						)
    lowercase__       :       Union[str, Any]				=						AutoModelForImageClassification.from_pretrained("""microsoft/dit-base-finetuned-rvlcdip"""						)
    model.to(lowerCamelCase__						)

    from datasets import load_dataset

    lowercase__       :       Any				=						load_dataset("""nielsr/rvlcdip-demo"""						)

    lowercase__       :       Dict				=						dataset["""train"""][0]["""image"""].convert("""RGB"""						)

    lowercase__       :       List[Any]				=						image_processor(lowerCamelCase__ ,     return_tensors="""pt"""						).to(lowerCamelCase__						)

    # forward pass
    with torch.no_grad():
     lowercase__       :       Optional[Any]				=						model(**lowerCamelCase__						)
     lowercase__       :       Union[str, Any]				=						outputs.logits

    lowercase__       :       Any				=						torch.Size((1, 16)						)
    self.assertEqual(logits.shape ,     lowerCamelCase__						)

    lowercase__       :       int				=						torch.tensor(
        [-0.4158, -0.4092, -0.4347] ,     device=lowerCamelCase__ ,     dtype=torch.float ,     )
    self.assertTrue(torch.allclose(logits[0, :3] ,     lowerCamelCase__ ,     atol=1E-4						)						)



"""simple docstring"""


from ..utils import DummyObject, requires_backends

class 				_SCREAMING_SNAKE_CASE				(							metaclass=__UpperCAmelCase  ):
   """simple docstring"""



   _a   :       Optional[int]									=    ['''note_seq''']


   def __init__(						self ,     *lowerCamelCase__ ,     **lowerCamelCase__						)      ->							Tuple:
    requires_backends(self ,     ["""note_seq"""]						)


   @classmethod
   def 					UpperCAmelCase__(						cls ,     *lowerCamelCase__ ,     **lowerCamelCase__						)      ->							Tuple:
    requires_backends(cls ,     ["""note_seq"""]						)







   @classmethod
   def 					UpperCAmelCase__(						cls ,     *lowerCamelCase__ ,     **lowerCamelCase__						)      ->							Tuple:
    requires_backends(cls ,     ["""note_seq"""]						)