





from typing import Optional

from torch import nn

from .transformer_ad import TransformeraDModel, TransformeraDModelOutput





class 					A_					(   nn.Module						):







       """simple docstring"""





       def __init__(     self						:						str    ,__A						:						int = 16    ,__A						:						int = 88    ,__A						:						Optional[int] = None    ,__A						:						int = 1    ,__A						:						float = 0.0    ,__A						:						int = 32    ,__A						:						Optional[int] = None    ,__A						:						bool = False    ,__A						:						Optional[int] = None    ,__A						:						Optional[int] = None    ,__A						:						str = "geglu"    ,__A						:						Optional[int] = None    ,)    ->       Optional[int]:
         super().__init__()
         _lowercase						    =			nn.ModuleList(
             [
                 TransformeraDModel(
                     num_attention_heads=__A    ,attention_head_dim=__A    ,in_channels=__A    ,num_layers=__A    ,dropout=__A    ,norm_num_groups=__A    ,cross_attention_dim=__A    ,attention_bias=__A    ,sample_size=__A    ,num_vector_embeds=__A    ,activation_fn=__A    ,num_embeds_ada_norm=__A    ,)
                 for _ in range(2	)
             ]	)

         # Variables that can be set by a pipeline:

         # The ratio of transformer1 to transformer2's output states to be combined during inference
         _lowercase						    =			0.5

         # The shape of `encoder_hidden_states` is expected to be
         # `(batch_size, condition_lengths[0]+condition_lengths[1], num_features)`
         _lowercase						    =			[77, 257]

         # Which transformer to use to encode which condition.
         # E.g. `(1, 0)` means that we'll use `transformers[1](conditions[0])` and `transformers[0](conditions[1])`
         _lowercase						    =			[1, 0]







       def  __UpperCAmelCase			(     self						:						Union[str, Any]    ,__A						:						Union[str, Any]    ,__A						:						Tuple    ,__A						:						Any=None    ,__A						:						Optional[int]=None    ,__A						:						Tuple=None    ,__A						:						bool = True    ,)    ->       Optional[Any]:
         _lowercase						    =			hidden_states

         _lowercase						    =			[]
         _lowercase						    =			0
         # attention_mask is not used yet
         for i in range(2	):
           # for each of the two transformers, pass the corresponding condition tokens
           _lowercase						    =			encoder_hidden_states[:, tokens_start : tokens_start + self.condition_lengths[i]]
           _lowercase						    =			self.transformer_index_for_condition[i]
           _lowercase						    =			self.transformers[transformer_index](
               __A    ,encoder_hidden_states=__A    ,timestep=__A    ,cross_attention_kwargs=__A    ,return_dict=__A    ,)[0]
           encoded_states.append(encoded_state - input_states	)
           tokens_start += self.condition_lengths[i]

         _lowercase						    =			encoded_states[0] * self.mix_ratio + encoded_states[1] * (1 - self.mix_ratio)
         _lowercase						    =			output_states + input_states

         if not return_dict:
           return (output_states,)

         return TransformeraDModelOutput(sample=__A	)






'''simple docstring'''




def 						__lowerCamelCase			(	UpperCAmelCase_ = 10_00							)   ->int:
	return sum(e for e in range(3					,				UpperCAmelCase_							) if e % 3 == 0 or e % 5 == 0							)


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



