

def    A_  (							a  ):

      """simple docstring"""



      if not isinstance(SCREAMING_SNAKE_CASE_					,   SCREAMING_SNAKE_CASE_  ):
            raise ValueError('multiplicative_persistence() only accepts integral values'  )
      if num < 0:
            raise ValueError('multiplicative_persistence() does not accept negative values'  )

      SCREAMING_SNAKE_CASE_				:  Union[str, Any]           =     0
      SCREAMING_SNAKE_CASE_				:  Dict           =     str(SCREAMING_SNAKE_CASE_  )

      while len(SCREAMING_SNAKE_CASE_  ) != 1:
            SCREAMING_SNAKE_CASE_				:  Tuple           =     [int(SCREAMING_SNAKE_CASE_  ) for i in num_string]

            SCREAMING_SNAKE_CASE_				:  List[str]           =     1
            for i in range(0					,   len(SCREAMING_SNAKE_CASE_  )  ):
                  total *= numbers[i]

            SCREAMING_SNAKE_CASE_				:  str           =     str(SCREAMING_SNAKE_CASE_  )

            steps += 1
      return steps

def    A_  (							a  ):

      """simple docstring"""



      if not isinstance(SCREAMING_SNAKE_CASE_					,   SCREAMING_SNAKE_CASE_  ):
            raise ValueError('additive_persistence() only accepts integral values'  )
      if num < 0:
            raise ValueError('additive_persistence() does not accept negative values'  )

      SCREAMING_SNAKE_CASE_				:  str           =     0
      SCREAMING_SNAKE_CASE_				:  Dict           =     str(SCREAMING_SNAKE_CASE_  )

      while len(SCREAMING_SNAKE_CASE_  ) != 1:
            SCREAMING_SNAKE_CASE_				:  Tuple           =     [int(SCREAMING_SNAKE_CASE_  ) for i in num_string]

            SCREAMING_SNAKE_CASE_				:  List[str]           =     0
            for i in range(0					,   len(SCREAMING_SNAKE_CASE_  )  ):
                  total += numbers[i]

            SCREAMING_SNAKE_CASE_				:  List[str]           =     str(SCREAMING_SNAKE_CASE_  )

            steps += 1
      return steps


if __name__ == "__main__":
    import doctest

    doctest.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):

  @slow
  def  UpperCAmelCase    (				self					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  List[str]           =     AutoImageProcessor.from_pretrained('microsoft/dit-base-finetuned-rvlcdip'					)
        SCREAMING_SNAKE_CASE_				:  Any           =     AutoModelForImageClassification.from_pretrained('microsoft/dit-base-finetuned-rvlcdip'					)
        model.to(_SCREAMING_SNAKE_CASE					)

        from datasets import load_dataset

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

        SCREAMING_SNAKE_CASE_				:  List[Any]           =     dataset['train'][0]['image'].convert('RGB'					)

        SCREAMING_SNAKE_CASE_				:  List[Any]           =     image_processor(_SCREAMING_SNAKE_CASE ,					return_tensors='pt'					).to(_SCREAMING_SNAKE_CASE					)

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

        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     torch.Size((1, 16)					)
        self.assertEqual(logits.shape ,					_SCREAMING_SNAKE_CASE					)

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






