






import torch
from torch import nn
from transformers import CLIPPreTrainedModel, CLIPVisionModel

from ...models.attention import BasicTransformerBlock
from ...utils import logging


lowerCamelCase__							=     logging.get_logger(__name__)  # pylint: disable=invalid-name







class 			snake_case__   (							lowercase_):

       '''simple docstring'''



       def __init__(							self			,						a__			,						a__=7_68    ) ->      List[str]:






            '''simple docstring'''





            super().__init__(a__    )
            __snake_case			:Union[str, Any]          =						proj_size

            __snake_case			:int          =						CLIPVisionModel(a__    )
            __snake_case			:List[Any]          =						PaintByExampleMapper(a__    )
            __snake_case			:Union[str, Any]          =						nn.LayerNorm(config.hidden_size    )
            __snake_case			:Any          =						nn.Linear(config.hidden_size			,						self.proj_size    )

            # uncondition for scaling
            __snake_case			:List[Any]          =						nn.Parameter(torch.randn((1, 1, self.proj_size)    )    )



       def 					__lowercase						(							self			,						a__			,						a__=False    ) ->      Optional[Any]:






            '''simple docstring'''





            __snake_case			:int          =						self.model(pixel_values=a__    )
            __snake_case			:List[Any]          =						clip_output.pooler_output
            __snake_case			:Tuple          =						self.mapper(latent_states[:, None]    )
            __snake_case			:int          =						self.final_layer_norm(a__    )
            __snake_case			:Union[str, Any]          =						self.proj_out(a__    )
            if return_uncond_vector:
                 return latent_states, self.uncond_vector

            return latent_states







class 			snake_case__   (							nn.Module):

       '''simple docstring'''



       def __init__(							self			,						a__    ) ->      Any:






            '''simple docstring'''





            super().__init__()
            __snake_case			:Optional[int]          =						(config.num_hidden_layers + 1) // 5
            __snake_case			:Optional[Any]          =						config.hidden_size
            __snake_case			:int          =						1
            __snake_case			:Any          =						nn.ModuleList(
                [
                    BasicTransformerBlock(a__			,						a__			,						a__			,						activation_fn="""gelu"""			,						attention_bias=a__    )
                    for _ in range(a__    )
                ]    )



       def 					__lowercase						(							self			,						a__    ) ->      Dict:






            '''simple docstring'''





            for block in self.blocks:
                 __snake_case			:Optional[Any]          =						block(a__    )

            return hidden_states










import math

lowerCamelCase__							=     10
lowerCamelCase__							=     7
lowerCamelCase__							=     BALLS_PER_COLOUR * NUM_COLOURS






def   UpperCamelCase  (       snake_case__     :   int = 20  ):




     '''simple docstring'''






     __snake_case			:Dict          =						math.comb(snake_case__	,snake_case__  )
     __snake_case			:int          =						math.comb(NUM_BALLS - BALLS_PER_COLOUR	,snake_case__  )

     __snake_case			:List[str]          =						NUM_COLOURS * (1 - missing_colour / total)

     return f'''{result:.9f}'''


if __name__ == "__main__":
     print(solution(20))


