






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





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


      '''simple docstring'''




      a  :    Dict       =     AutoImageProcessor.from_pretrained('microsoft/dit-base-finetuned-rvlcdip'    )
      a  :    str       =     AutoModelForImageClassification.from_pretrained('microsoft/dit-base-finetuned-rvlcdip'    )
      model.to(A    )

      from datasets import load_dataset

      a  :    str       =     load_dataset('nielsr/rvlcdip-demo'    )

      a  :    str       =     dataset['train'][0]['image'].convert('RGB'    )

      a  :    Dict       =     image_processor(A       ,	return_tensors='pt'    ).to(A    )

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

      a  :    Any       =     torch.Size((1, 1_6)    )
      self.assertEqual(logits.shape       ,	A    )

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












"""simple docstring"""


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_UpperCamelCase       :					int									=		{
    'configuration_time_series_transformer': [
        'TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'TimeSeriesTransformerConfig',
    ],
}

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _UpperCamelCase       :					Optional[Any]									=		[
       'TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
       'TimeSeriesTransformerForPrediction',
       'TimeSeriesTransformerModel',
       'TimeSeriesTransformerPreTrainedModel',
   ]


if TYPE_CHECKING:
   from .configuration_time_series_transformer import (
       TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
       TimeSeriesTransformerConfig,
   )

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_time_series_transformer import (
          TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
          TimeSeriesTransformerForPrediction,
          TimeSeriesTransformerModel,
          TimeSeriesTransformerPreTrainedModel,
      )

else:
   import sys

   _UpperCamelCase       :					List[str]									=		_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)




