


'''simple docstring'''



import math






def     lowerCamelCase				(_SCREAMING_SNAKE_CASE :  int  ):
					assert isinstance(_lowercase		, _lowercase  ) and (
					    number >= 0
					), "'number' must been an int and positive"

					if 1 < number < 4:
										# 2 and 3 are primes
										return True
					elif number < 2 or not number % 2:
										# Negatives, 0, 1 and all even numbers are not primes
										return False

					__a     :			str          =    range(3		, int(math.sqrt(_lowercase  ) + 1  )		, 2  )
					return not any(not number % i for i in odd_numbers  )






def     lowerCamelCase				(_SCREAMING_SNAKE_CASE :  Union[str, Any]		, _SCREAMING_SNAKE_CASE :  Union[str, Any]=1		, **_SCREAMING_SNAKE_CASE :  Optional[Any]  ):
					__a     :			Any          =    factor * value
					__a     :			List[str]          =    value

					while not is_prime(_lowercase  ):
										value += 1 if not ("desc" in kwargs and kwargs["desc"] is True) else -1

					if value == first_value_val:
										return next_prime(value + 1		, **_lowercase  )
					return value









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






    """simple docstring"""





    @slow
    def 				a__ ( self    )					->						List[str]:
         UpperCAmelCase_     :				Tuple  =     AutoImageProcessor.from_pretrained('''microsoft/dit-base-finetuned-rvlcdip'''    )
         UpperCAmelCase_     :				Union[str, Any]  =     AutoModelForImageClassification.from_pretrained('''microsoft/dit-base-finetuned-rvlcdip'''    )
         model.to(_SCREAMING_SNAKE_CASE    )

         from datasets import load_dataset

         UpperCAmelCase_     :				Optional[int]  =     load_dataset('''nielsr/rvlcdip-demo'''    )

         UpperCAmelCase_     :				Optional[Any]  =     dataset['''train'''][0]['''image'''].convert('''RGB'''    )

         UpperCAmelCase_     :				str  =     image_processor(_SCREAMING_SNAKE_CASE  ,return_tensors='''pt'''    ).to(_SCREAMING_SNAKE_CASE    )

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

         UpperCAmelCase_     :				Tuple  =     torch.Size((1, 16)    )
         self.assertEqual(logits.shape  ,_SCREAMING_SNAKE_CASE    )

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