

'''simple docstring'''

import copy
import os
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union


if TYPE_CHECKING:
    from ...processing_utils import ProcessorMixin
    from ...utils import TensorType

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


A_       						=							logging.get_logger(__name__)

A_       						=							{
    "google/owlvit-base-patch32": "https://huggingface.co/google/owlvit-base-patch32/resolve/main/config.json",
    "google/owlvit-base-patch16": "https://huggingface.co/google/owlvit-base-patch16/resolve/main/config.json",
    "google/owlvit-large-patch14": "https://huggingface.co/google/owlvit-large-patch14/resolve/main/config.json",
}





class 							_snake_case (       _a						):
   _A       :     Tuple       =					'''owlvit_text_model'''
   def __init__( self			:      List[str]     ,SCREAMING_SNAKE_CASE__			:      Union[str, Any]=49_408     ,SCREAMING_SNAKE_CASE__			:      List[Any]=512     ,SCREAMING_SNAKE_CASE__			:      Dict=2_048     ,SCREAMING_SNAKE_CASE__			:      List[Any]=12     ,SCREAMING_SNAKE_CASE__			:      List[Any]=8     ,SCREAMING_SNAKE_CASE__			:      Any=16     ,SCREAMING_SNAKE_CASE__			:      Dict="quick_gelu"     ,SCREAMING_SNAKE_CASE__			:      int=1e-5     ,SCREAMING_SNAKE_CASE__			:      int=0.0     ,SCREAMING_SNAKE_CASE__			:      int=0.02     ,SCREAMING_SNAKE_CASE__			:      List[str]=1.0     ,SCREAMING_SNAKE_CASE__			:      str=0     ,SCREAMING_SNAKE_CASE__			:      int=49_406     ,SCREAMING_SNAKE_CASE__			:      Dict=49_407     ,**SCREAMING_SNAKE_CASE__			:      List[Any]     ,):
     super().__init__(pad_token_id=SCREAMING_SNAKE_CASE__     ,bos_token_id=SCREAMING_SNAKE_CASE__     ,eos_token_id=SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:Optional[Any]						      =					vocab_size
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					hidden_size
     SCREAMING_SNAKE_CASE:Optional[int]						      =					intermediate_size
     SCREAMING_SNAKE_CASE:Tuple						      =					num_hidden_layers
     SCREAMING_SNAKE_CASE:List[Any]						      =					num_attention_heads
     SCREAMING_SNAKE_CASE:int						      =					max_position_embeddings
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					hidden_act
     SCREAMING_SNAKE_CASE:List[Any]						      =					layer_norm_eps
     SCREAMING_SNAKE_CASE:List[Any]						      =					attention_dropout
     SCREAMING_SNAKE_CASE:Dict						      =					initializer_range
     SCREAMING_SNAKE_CASE:int						      =					initializer_factor







   @classmethod
   def     __UpperCamelCase						( cls			:      Dict     ,SCREAMING_SNAKE_CASE__			:      Union[str, os.PathLike]     ,**SCREAMING_SNAKE_CASE__			:      Tuple							):
     cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE:Dict						      =					cls.get_config_dict(SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)

     # get the text config dict if we are loading from OwlViTConfig
     if config_dict.get("model_type"							) == "owlvit":
       SCREAMING_SNAKE_CASE:Dict						      =					config_dict["text_config"]

     if "model_type" in config_dict and hasattr(cls     ,"model_type"							) and config_dict["model_type"] != cls.model_type:
       logger.warning(
           F'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
           F'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''							)

     return cls.from_dict(SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)





class 							_snake_case (       _a						):
   _A       :     Optional[int]       =					'''owlvit_vision_model'''
   def __init__( self			:      str     ,SCREAMING_SNAKE_CASE__			:      Any=768     ,SCREAMING_SNAKE_CASE__			:      str=3_072     ,SCREAMING_SNAKE_CASE__			:      Optional[int]=12     ,SCREAMING_SNAKE_CASE__			:      str=12     ,SCREAMING_SNAKE_CASE__			:      Dict=3     ,SCREAMING_SNAKE_CASE__			:      Dict=768     ,SCREAMING_SNAKE_CASE__			:      Optional[int]=32     ,SCREAMING_SNAKE_CASE__			:      Dict="quick_gelu"     ,SCREAMING_SNAKE_CASE__			:      Union[str, Any]=1e-5     ,SCREAMING_SNAKE_CASE__			:      List[str]=0.0     ,SCREAMING_SNAKE_CASE__			:      Tuple=0.02     ,SCREAMING_SNAKE_CASE__			:      str=1.0     ,**SCREAMING_SNAKE_CASE__			:      str     ,):
     super().__init__(**SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:int						      =					hidden_size
     SCREAMING_SNAKE_CASE:Any						      =					intermediate_size
     SCREAMING_SNAKE_CASE:List[str]						      =					num_hidden_layers
     SCREAMING_SNAKE_CASE:str						      =					num_attention_heads
     SCREAMING_SNAKE_CASE:str						      =					num_channels
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					image_size
     SCREAMING_SNAKE_CASE:Optional[int]						      =					patch_size
     SCREAMING_SNAKE_CASE:Dict						      =					hidden_act
     SCREAMING_SNAKE_CASE:Tuple						      =					layer_norm_eps
     SCREAMING_SNAKE_CASE:Optional[int]						      =					attention_dropout
     SCREAMING_SNAKE_CASE:Optional[int]						      =					initializer_range
     SCREAMING_SNAKE_CASE:int						      =					initializer_factor







   @classmethod
   def     __UpperCamelCase						( cls			:      Optional[int]     ,SCREAMING_SNAKE_CASE__			:      Union[str, os.PathLike]     ,**SCREAMING_SNAKE_CASE__			:      Any							):
     cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE:Optional[Any]						      =					cls.get_config_dict(SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)

     # get the vision config dict if we are loading from OwlViTConfig
     if config_dict.get("model_type"							) == "owlvit":
       SCREAMING_SNAKE_CASE:List[Any]						      =					config_dict["vision_config"]

     if "model_type" in config_dict and hasattr(cls     ,"model_type"							) and config_dict["model_type"] != cls.model_type:
       logger.warning(
           F'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
           F'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''							)

     return cls.from_dict(SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)





class 							_snake_case (       _a						):
   _A       :     Union[str, Any]       =					'''owlvit'''
   _A       :     Optional[Any]       =					True
   def __init__( self			:      Tuple     ,SCREAMING_SNAKE_CASE__			:      Optional[Any]=None     ,SCREAMING_SNAKE_CASE__			:      Optional[Any]=None     ,SCREAMING_SNAKE_CASE__			:      List[str]=512     ,SCREAMING_SNAKE_CASE__			:      List[Any]=2.6_592     ,SCREAMING_SNAKE_CASE__			:      Tuple=True     ,**SCREAMING_SNAKE_CASE__			:      str     ,):
     super().__init__(**SCREAMING_SNAKE_CASE__							)

     if text_config is None:
       SCREAMING_SNAKE_CASE:Tuple						      =					{}
       logger.info("text_config is None. Initializing the OwlViTTextConfig with default values."							)

     if vision_config is None:
       SCREAMING_SNAKE_CASE:Dict						      =					{}
       logger.info("vision_config is None. initializing the OwlViTVisionConfig with default values."							)

     SCREAMING_SNAKE_CASE:str						      =					OwlViTTextConfig(**SCREAMING_SNAKE_CASE__							)
     SCREAMING_SNAKE_CASE:int						      =					OwlViTVisionConfig(**SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					projection_dim
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					logit_scale_init_value
     SCREAMING_SNAKE_CASE:Optional[int]						      =					return_dict
     SCREAMING_SNAKE_CASE:Optional[int]						      =					1.0
   @classmethod
   def     __UpperCamelCase						( cls			:      str     ,SCREAMING_SNAKE_CASE__			:      Union[str, os.PathLike]     ,**SCREAMING_SNAKE_CASE__			:      Dict							):
     cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE:List[str]						      =					cls.get_config_dict(SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)

     if "model_type" in config_dict and hasattr(cls     ,"model_type"							) and config_dict["model_type"] != cls.model_type:
       logger.warning(
           F'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
           F'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''							)

     return cls.from_dict(SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)
   @classmethod
   def     __UpperCamelCase						( cls			:      List[str]     ,SCREAMING_SNAKE_CASE__			:      Dict     ,SCREAMING_SNAKE_CASE__			:      Dict     ,**SCREAMING_SNAKE_CASE__			:      Any							):
     SCREAMING_SNAKE_CASE:str						      =					{}
     SCREAMING_SNAKE_CASE:List[str]						      =					text_config
     SCREAMING_SNAKE_CASE:Tuple						      =					vision_config

     return cls.from_dict(SCREAMING_SNAKE_CASE__     ,**SCREAMING_SNAKE_CASE__							)







   def     __UpperCamelCase						( self			:      Union[str, Any]							):
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					copy.deepcopy(self.__dict__							)
     SCREAMING_SNAKE_CASE:int						      =					self.text_config.to_dict()
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					self.vision_config.to_dict()
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					self.__class__.model_type
     return output





class 							_snake_case (       _a						):
   @property
   def     __UpperCamelCase						( self			:      List[Any]							):
     return OrderedDict(
         [
             ("input_ids", {0: "batch", 1: "sequence"}),
             ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
             ("attention_mask", {0: "batch", 1: "sequence"}),
         ]							)
   @property
   def     __UpperCamelCase						( self			:      int							):
     return OrderedDict(
         [
             ("logits_per_image", {0: "batch"}),
             ("logits_per_text", {0: "batch"}),
             ("text_embeds", {0: "batch"}),
             ("image_embeds", {0: "batch"}),
         ]							)
   @property
   def     __UpperCamelCase						( self			:      Optional[Any]							):
     return 1e-4
   def     __UpperCamelCase						( self			:      Tuple     ,SCREAMING_SNAKE_CASE__			:      "ProcessorMixin"     ,SCREAMING_SNAKE_CASE__			:      int = -1     ,SCREAMING_SNAKE_CASE__			:      int = -1     ,SCREAMING_SNAKE_CASE__			:      Optional["TensorType"] = None     ,):
     SCREAMING_SNAKE_CASE:List[Any]						      =					super().generate_dummy_inputs(
         processor.tokenizer     ,batch_size=SCREAMING_SNAKE_CASE__     ,seq_length=SCREAMING_SNAKE_CASE__     ,framework=SCREAMING_SNAKE_CASE__							)
     SCREAMING_SNAKE_CASE:List[Any]						      =					super().generate_dummy_inputs(
         processor.image_processor     ,batch_size=SCREAMING_SNAKE_CASE__     ,framework=SCREAMING_SNAKE_CASE__							)
     return {**text_input_dict, **image_input_dict}







   @property
   def     __UpperCamelCase						( self			:      Optional[Any]							):
     return 14









'''simple docstring'''

from math import factorial





def    A_  ( snake_case      ,       snake_case ):

  # If either of the conditions are true, the function is being asked
  # to calculate a factorial of a negative number, which is not possible
  if n < k or k < 0:
    raise ValueError("Please enter positive integers for n and k where n >= k" )
  return factorial(snake_case ) // (factorial(snake_case ) * factorial(n - k ))


if __name__ == "__main__":
    print(
        "The number of five-card hands possible from a standard",
        f'''fifty-two card deck is: {combinations(52, 5)}\n''',
    )

    print(
        "If a class of 40 students must be arranged into groups of",
        f'''4 for group projects, there are {combinations(40, 4)} ways''',
        "to arrange them.\n",
    )

    print(
        "If 10 teams are competing in a Formula One race, there",
        f'''are {combinations(10, 3)} ways that first, second and''',
        "third place can be awarded.",
    )






