

"""simple docstring"""



from typing import Any, Dict, List, Union

from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends
from .base import PIPELINE_INIT_ARGS, ChunkPipeline


if is_vision_available():
 from PIL import Image

 from ..image_utils import load_image

if is_torch_available():
 import torch

 from transformers.modeling_outputs import BaseModelOutput

 from ..models.auto.modeling_auto import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING

SCREAMING_SNAKE_CASE_					:	Optional[Any]							  =						logging.get_logger(__name__)



@add_end_docstrings(_lowerCamelCase				)
class 					a						(       _lowerCamelCase				):



    """simple docstring"""



    def __init__(     self: Optional[int]    ,						**UpperCamelCase: Optional[Any]       ):






         """simple docstring"""


         super().__init__(**UpperCamelCase       )

         if self.framework == "tf":
              raise ValueError(f"""The {self.__class__} is only available in PyTorch."""       )

         requires_backends(self    ,						"""vision"""       )
         self.check_model_type(UpperCamelCase       )

    def __call__(     self: Union[str, Any]    ,						UpperCamelCase: Union[str, "Image.Image", List[Dict[str, Any]]]    ,						UpperCamelCase: Union[str, List[str]] = None    ,						**UpperCamelCase: int    ,						):






         """simple docstring"""


         if "text_queries" in kwargs:
              A__										=  kwargs.pop("""text_queries"""       )

         if isinstance(UpperCamelCase    ,						(str, Image.Image)       ):
              A__										=  {"""image""": image, """candidate_labels""": candidate_labels}
         else:
              A__										=  image
         A__										=  super().__call__(UpperCamelCase    ,						**UpperCamelCase       )
         return results

    def 				UpperCamelCase	(     self: int    ,						**UpperCamelCase: Any       ):






         """simple docstring"""


         A__										=  {}
         if "threshold" in kwargs:
              A__										=  kwargs["""threshold"""]
         if "top_k" in kwargs:
              A__										=  kwargs["""top_k"""]
         return {}, {}, postprocess_params

    def 				UpperCamelCase	(     self: str    ,						UpperCamelCase: Any       ):






         """simple docstring"""


         A__										=  load_image(inputs["""image"""]       )
         A__										=  inputs["""candidate_labels"""]
         if isinstance(UpperCamelCase    ,						UpperCamelCase       ):
              A__										=  candidate_labels.split(""","""       )

         A__										=  torch.tensor([[image.height, image.width]]    ,						dtype=torch.intaa       )
         for i, candidate_label in enumerate(UpperCamelCase       ):
              A__										=  self.tokenizer(UpperCamelCase    ,						return_tensors=self.framework       )
              A__										=  self.image_processor(UpperCamelCase    ,						return_tensors=self.framework       )
              yield {
                  "is_last": i == len(UpperCamelCase       ) - 1,
                  "target_size": target_size,
                  "candidate_label": candidate_label,
                  **text_inputs,
                  **image_features,
              }

    def 				UpperCamelCase	(     self: int    ,						UpperCamelCase: Tuple       ):






         """simple docstring"""


         A__										=  model_inputs.pop("""target_size"""       )
         A__										=  model_inputs.pop("""candidate_label"""       )
         A__										=  model_inputs.pop("""is_last"""       )

         A__										=  self.model(**UpperCamelCase       )

         A__										=  {"""target_size""": target_size, """candidate_label""": candidate_label, """is_last""": is_last, **outputs}
         return model_outputs

    def 				UpperCamelCase	(     self: str    ,						UpperCamelCase: Any    ,						UpperCamelCase: int=0.1    ,						UpperCamelCase: Union[str, Any]=None       ):






         """simple docstring"""


         A__										=  []
         for model_output in model_outputs:
              A__										=  model_output["""candidate_label"""]
              A__										=  BaseModelOutput(UpperCamelCase       )
              A__										=  self.image_processor.post_process_object_detection(
                  outputs=UpperCamelCase    ,						threshold=UpperCamelCase    ,						target_sizes=model_output["""target_size"""]       )[0]

              for index in outputs["scores"].nonzero():
                   A__										=  outputs["""scores"""][index].item()
                   A__										=  self._get_bounding_box(outputs["""boxes"""][index][0]       )

                   A__										=  {"""score""": score, """label""": label, """box""": box}
                   results.append(UpperCamelCase       )

         A__										=  sorted(UpperCamelCase    ,						key=lambda UpperCamelCase       : x["score"]    ,						reverse=UpperCamelCase       )
         if top_k:
              A__										=  results[:top_k]

         return results





    def 				UpperCamelCase	(     self: str    ,						UpperCamelCase: "torch.Tensor"       ):






         """simple docstring"""


         if self.framework != "pt":
              raise ValueError("""The ZeroShotObjectDetectionPipeline is only available in PyTorch."""       )
         A__			,				A__			,				A__			,				A__										=  box.int().tolist()
         A__										=  {
             """xmin""": xmin,
             """ymin""": ymin,
             """xmax""": xmax,
             """ymax""": ymax,
         }
         return bbox









"""simple docstring"""



def  _snake_case     (    UpperCAmelCase_  :					int			):
     A__										=  1
     for i in range(1					,   num + 1			):
          fact *= i
     return fact





def  _snake_case     (    UpperCAmelCase_  :					int			):
     A__										=  0
     while number > 0:
          A__										=  number % 10
          sum_of_digits += last_digit
          A__										=  number // 10  # Removing the last_digit from the given number
     return sum_of_digits





def  _snake_case     (    UpperCAmelCase_  :					int = 100			):
     A__										=  factorial(UpperCAmelCase_			)
     A__										=  split_and_add(UpperCAmelCase_			)
     return result


if __name__ == "__main__":
 print(solution(int(input('Enter the Number: ').strip())))






