




from collections.abc import Iterable
from typing import Generic, TypeVar

__a							     =					TypeVar('_T')

class     __a(	Generic[_T]  ):






    """simple docstring"""





    def __init__( self  ,_SCREAMING_SNAKE_CASE = None    )					->						None:
         UpperCAmelCase_     :				list[_T]  =     list(iterable or []    )
         UpperCAmelCase_     :				list[_T]  =     []





    def __len__( self    )					->						int:
         return len(self._stacka    ) + len(self._stacka    )





    def __repr__( self    )					->						str:
         return f'''Queue({tuple(self._stacka[::-1] + self._stacka    )})'''





    def 				a__ ( self  ,_SCREAMING_SNAKE_CASE    )					->						None:
         self._stacka.append(_SCREAMING_SNAKE_CASE    )





    def 				a__ ( self    )					->						_T:
         UpperCAmelCase_     :				str  =     self._stacka.pop
         UpperCAmelCase_     :				List[str]  =     self._stacka.append

         if not self._stacka:
              while self._stacka:
                   stacka_append(stacka_pop()    )

         if not self._stacka:
              raise IndexError('''Queue is empty'''    )
         return self._stacka.pop()


if __name__ == "__main__":
     from doctest import testmod

     testmod()





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    )    )