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    ):
  """simple docstring"""







  @slow
  def       __A   (							self       :				Any      )     ->		Tuple:
        SCREAMING_SNAKE_CASE_      =     AutoImageProcessor.from_pretrained("microsoft/dit-base-finetuned-rvlcdip"      )
        SCREAMING_SNAKE_CASE_      =     AutoModelForImageClassification.from_pretrained("microsoft/dit-base-finetuned-rvlcdip"      )
        model.to(__magic_name__      )

        from datasets import load_dataset

        SCREAMING_SNAKE_CASE_      =     load_dataset("nielsr/rvlcdip-demo"      )

        SCREAMING_SNAKE_CASE_      =     dataset["train"][0]["image"].convert("RGB"      )

        SCREAMING_SNAKE_CASE_      =     image_processor(__magic_name__     ,   return_tensors="pt"      ).to(__magic_name__      )

        # forward pass
        with torch.no_grad():
              SCREAMING_SNAKE_CASE_      =     model(**__magic_name__      )
              SCREAMING_SNAKE_CASE_      =     outputs.logits

        SCREAMING_SNAKE_CASE_      =     torch.Size((1, 16)      )
        self.assertEqual(logits.shape     ,   __magic_name__      )

        SCREAMING_SNAKE_CASE_      =     torch.tensor(
            [-0.4158, -0.4092, -0.4347]     ,   device=__magic_name__     ,   dtype=torch.float     ,   )
        self.assertTrue(torch.allclose(logits[0, :3]     ,   __magic_name__     ,   atol=1e-4      )      )



from dataclasses import dataclass
from enum import Enum
from typing import List, Optional, Union

import numpy as np
import PIL
from PIL import Image

from ...utils import BaseOutput, is_torch_available, is_transformers_available


@dataclass
class      lowerCamelCase    (SCREAMING_SNAKE_CASE__    ):
  """simple docstring"""







  lowerCamelCase__   =  42
  lowerCamelCase__   =  42


if is_transformers_available() and is_torch_available():
      from .pipeline_semantic_stable_diffusion import SemanticStableDiffusionPipeline


