






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




    @slow
    def 				lowerCAmelCase__				(			self  :       List[Any]			):






       '''simple docstring'''






       lowercase_	:    Dict           =     AutoImageProcessor.from_pretrained("microsoft/dit-base-finetuned-rvlcdip"			)
       lowercase_	:    Dict           =     AutoModelForImageClassification.from_pretrained("microsoft/dit-base-finetuned-rvlcdip"			)
       model.to(a			)

       from datasets import load_dataset

       lowercase_	:    List[Any]           =     load_dataset("nielsr/rvlcdip-demo"			)

       lowercase_	:    Optional[int]           =     dataset["train"][0]["image"].convert("RGB"			)

       lowercase_	:    Dict           =     image_processor(a  ,     return_tensors="pt"			).to(a			)

       # forward pass
       with torch.no_grad():
          lowercase_	:    List[Any]           =     model(**a			)
          lowercase_	:    Optional[Any]           =     outputs.logits

       lowercase_	:    Optional[int]           =     torch.Size((1, 1_6)			)
       self.assertEqual(logits.shape  ,     a			)

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












'''simple docstring'''
# limitations under the License.

# NOTE: This file is deprecated and will be removed in a future version.
# It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works

from .pipelines import DiffusionPipeline, ImagePipelineOutput  # noqa: F401
from .utils import deprecate


deprecate(
    'pipelines_utils',
    '0.22.0',
    'Importing `DiffusionPipeline` or `ImagePipelineOutput` from diffusers.pipeline_utils is deprecated. Please import from diffusers.pipelines.pipeline_utils instead.',
    standard_warn=False,
    stacklevel=3,
)




