






"""simple docstring"""
from typing import List, Union

from ..utils import (
    add_end_docstrings,
    is_tf_available,
    is_torch_available,
    is_vision_available,
    logging,
    requires_backends,
)
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_vision_available():
 from PIL import Image

 from ..image_utils import load_image

if is_tf_available():
 import tensorflow as tf

 from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
 from ..tf_utils import stable_softmax

if is_torch_available():
 from ..models.auto.modeling_auto import MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING

snake_case : Tuple     		=		logging.get_logger(__name__)



@add_end_docstrings(a_)
class        UpperCamelCase__ (				a_):







    """simple docstring"""







    def __init__(		self :	Optional[Any]				,    *UpperCamelCase_ :	Dict				,    **UpperCamelCase_ :	str ):





           '''simple docstring'''

           super().__init__(*UpperCamelCase_				,    **UpperCamelCase_ )
           requires_backends(self				,    'vision' )
           self.check_model_type(
               TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
               if self.framework == 'tf'
               else MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING )







    def 				a__			(		self :	Tuple				,    UpperCamelCase_ :	List[Any]=None ):





           '''simple docstring'''

           __magic_name__      				=    {}
           if top_k is not None:
                  __magic_name__      				=    top_k
           return {}, {}, postprocess_params







    def __call__(		self :	Tuple				,    UpperCamelCase_ :	Union[str, List[str], "Image.Image", List["Image.Image"]]				,    **UpperCamelCase_ :	Optional[int] ):





           '''simple docstring'''

           return super().__call__(UpperCamelCase_				,    **UpperCamelCase_ )







    def 				a__			(		self :	Optional[Any]				,    UpperCamelCase_ :	Union[str, Any] ):





           '''simple docstring'''

           __magic_name__      				=    load_image(UpperCamelCase_ )
           __magic_name__      				=    self.image_processor(images=UpperCamelCase_				,    return_tensors=self.framework )
           return model_inputs







    def 				a__			(		self :	Any				,    UpperCamelCase_ :	int ):





           '''simple docstring'''

           __magic_name__      				=    self.model(**UpperCamelCase_ )
           return model_outputs







    def 				a__			(		self :	int				,    UpperCamelCase_ :	Optional[Any]				,    UpperCamelCase_ :	Union[str, Any]=5 ):





           '''simple docstring'''

           if top_k > self.model.config.num_labels:
                  __magic_name__      				=    self.model.config.num_labels

           if self.framework == "pt":
                  __magic_name__      				=    model_outputs.logits.softmax(-1 )[0]
                  __magic_name__				,  __magic_name__      				=    probs.topk(UpperCamelCase_ )
           elif self.framework == "tf":
                  __magic_name__      				=    stable_softmax(model_outputs.logits				,    axis=-1 )[0]
                  __magic_name__      				=    tf.math.top_k(UpperCamelCase_				,    k=UpperCamelCase_ )
                  __magic_name__				,  __magic_name__      				=    topk.values.numpy(), topk.indices.numpy()
           else:
                  raise ValueError(f"""Unsupported framework: {self.framework}""" )

           __magic_name__      				=    scores.tolist()
           __magic_name__      				=    ids.tolist()
           return [{"score": score, "label": self.model.config.idalabel[_id]} for score, _id in zip(UpperCamelCase_				,    UpperCamelCase_ )]







"""simple docstring"""
def 							A						(				__snake_case: int  )    ->		int:

       """simple docstring"""





       if divisor % 5 == 0 or divisor % 2 == 0:
              return 0
       __magic_name__      				=    1
       __magic_name__      				=    1
       while repunit:
              __magic_name__      				=    (1_0 * repunit + 1) % divisor
              repunit_index += 1
       return repunit_index


def 							A						(				__snake_case: int = 1_0_0_0_0_0_0  )    ->		int:

       """simple docstring"""





       __magic_name__      				=    limit - 1
       if divisor % 2 == 0:
              divisor += 1
       while least_divisible_repunit(__snake_case  ) <= limit:
              divisor += 2
       return divisor


if __name__ == "__main__":
 print(f"""{solution() = }""")