




from typing import Any, Dict, Optional

import torch
import torch.nn.functional as F
from torch import nn

from ..utils import maybe_allow_in_graph
from .activations import get_activation
from .attention_processor import Attention
from .embeddings import CombinedTimestepLabelEmbeddings







@maybe_allow_in_graph
class   A(						nn.Module       ):



 '''simple docstring'''


 def __init__(    self :  Optional[Any]						,							A_ :  int						,							A_ :  int						,							A_ :  int						,							A_ :  int=0.0						,							A_ :  Optional[int] = None						,							A_ :  str = "geglu"						,							A_ :  Optional[int] = None						,							A_ :  bool = False						,							A_ :  bool = False						,							A_ :  bool = False						,							A_ :  bool = False						,							A_ :  bool = True						,							A_ :  str = "layer_norm"						,							A_ :  bool = False						,							)       ->     Any:

       """simple docstring"""






       super().__init__()
       lowerCamelCase_							=   only_cross_attention

       lowerCamelCase_							=   (num_embeds_ada_norm is not None) and norm_type == 'ada_norm_zero'
       lowerCamelCase_							=   (num_embeds_ada_norm is not None) and norm_type == 'ada_norm'

       if norm_type in ("ada_norm", "ada_norm_zero") and num_embeds_ada_norm is None:
             raise ValueError(
                 f"""`norm_type` is set to {norm_type}, but `num_embeds_ada_norm` is not defined. Please make sure to"""
                 f""" define `num_embeds_ada_norm` if setting `norm_type` to {norm_type}."""  )

       # Define 3 blocks. Each block has its own normalization layer.
       # 1. Self-Attn
       if self.use_ada_layer_norm:
             lowerCamelCase_							=   AdaLayerNorm(A_						,							A_  )
       elif self.use_ada_layer_norm_zero:
             lowerCamelCase_							=   AdaLayerNormZero(A_						,							A_  )
       else:
             lowerCamelCase_							=   nn.LayerNorm(A_						,							elementwise_affine=A_  )
       lowerCamelCase_							=   Attention(
           query_dim=A_						,							heads=A_						,							dim_head=A_						,							dropout=A_						,							bias=A_						,							cross_attention_dim=cross_attention_dim if only_cross_attention else None						,							upcast_attention=A_						,							)

       # 2. Cross-Attn
       if cross_attention_dim is not None or double_self_attention:
             # We currently only use AdaLayerNormZero for self attention where there will only be one attention block.
             # I.e. the number of returned modulation chunks from AdaLayerZero would not make sense if returned during
             # the second cross attention block.
             lowerCamelCase_							=   (
                 AdaLayerNorm(A_						,							A_  )
                 if self.use_ada_layer_norm
                 else nn.LayerNorm(A_						,							elementwise_affine=A_  )
             )
             lowerCamelCase_							=   Attention(
                 query_dim=A_						,							cross_attention_dim=cross_attention_dim if not double_self_attention else None						,							heads=A_						,							dim_head=A_						,							dropout=A_						,							bias=A_						,							upcast_attention=A_						,							)  # is self-attn if encoder_hidden_states is none
       else:
             lowerCamelCase_							=   None
             lowerCamelCase_							=   None

       # 3. Feed-forward
       lowerCamelCase_							=   nn.LayerNorm(A_						,							elementwise_affine=A_  )
       lowerCamelCase_							=   FeedForward(A_						,							dropout=A_						,							activation_fn=A_						,							final_dropout=A_  )

       # let chunk size default to None
       lowerCamelCase_							=   None
       lowerCamelCase_							=   0

 def     a__			(    self :  Optional[Any]						,							A_ :  Optional[int]						,							A_ :  int  )       ->     List[str]:

       """simple docstring"""






       lowerCamelCase_							=   chunk_size
       lowerCamelCase_							=   dim





 def     a__			(    self :  Dict						,							A_ :  torch.FloatTensor						,							A_ :  Optional[torch.FloatTensor] = None						,							A_ :  Optional[torch.FloatTensor] = None						,							A_ :  Optional[torch.FloatTensor] = None						,							A_ :  Optional[torch.LongTensor] = None						,							A_ :  Dict[str, Any] = None						,							A_ :  Optional[torch.LongTensor] = None						,							)       ->     List[str]:

       """simple docstring"""






       if self.use_ada_layer_norm:
             lowerCamelCase_							=   self.norma(A_						,							A_  )
       elif self.use_ada_layer_norm_zero:
             lowerCamelCase_					,    lowerCamelCase_					,    lowerCamelCase_					,    lowerCamelCase_					,    lowerCamelCase_							=   self.norma(
                 A_						,							A_						,							A_						,							hidden_dtype=hidden_states.dtype  )
       else:
             lowerCamelCase_							=   self.norma(A_  )

       lowerCamelCase_							=   cross_attention_kwargs if cross_attention_kwargs is not None else {}

       lowerCamelCase_							=   self.attna(
           A_						,							encoder_hidden_states=encoder_hidden_states if self.only_cross_attention else None						,							attention_mask=A_						,							**A_						,							)
       if self.use_ada_layer_norm_zero:
             lowerCamelCase_							=   gate_msa.unsqueeze(1  ) * attn_output
       lowerCamelCase_							=   attn_output + hidden_states

       # 2. Cross-Attention
       if self.attna is not None:
             lowerCamelCase_							=   (
                 self.norma(A_						,							A_  ) if self.use_ada_layer_norm else self.norma(A_  )
             )

             lowerCamelCase_							=   self.attna(
                 A_						,							encoder_hidden_states=A_						,							attention_mask=A_						,							**A_						,							)
             lowerCamelCase_							=   attn_output + hidden_states

       # 3. Feed-forward
       lowerCamelCase_							=   self.norma(A_  )

       if self.use_ada_layer_norm_zero:
             lowerCamelCase_							=   norm_hidden_states * (1 + scale_mlp[:, None]) + shift_mlp[:, None]

       if self._chunk_size is not None:
             # "feed_forward_chunk_size" can be used to save memory
             if norm_hidden_states.shape[self._chunk_dim] % self._chunk_size != 0:
                   raise ValueError(
                       f"""`hidden_states` dimension to be chunked: {norm_hidden_states.shape[self._chunk_dim]} has to be divisible by chunk size: {self._chunk_size}. Make sure to set an appropriate `chunk_size` when calling `unet.enable_forward_chunking`."""  )

             lowerCamelCase_							=   norm_hidden_states.shape[self._chunk_dim] // self._chunk_size
             lowerCamelCase_							=   torch.cat(
                 [self.ff(A_  ) for hid_slice in norm_hidden_states.chunk(A_						,							dim=self._chunk_dim  )]						,							dim=self._chunk_dim						,							)
       else:
             lowerCamelCase_							=   self.ff(A_  )

       if self.use_ada_layer_norm_zero:
             lowerCamelCase_							=   gate_mlp.unsqueeze(1  ) * ff_output

       lowerCamelCase_							=   ff_output + hidden_states

       return hidden_states







class   A(						nn.Module       ):



 '''simple docstring'''


 def __init__(    self :  Tuple						,							A_ :  int						,							A_ :  Optional[int] = None						,							A_ :  int = 4						,							A_ :  float = 0.0						,							A_ :  str = "geglu"						,							A_ :  bool = False						,							)       ->     List[str]:

       """simple docstring"""






       super().__init__()
       lowerCamelCase_							=   int(dim * mult  )
       lowerCamelCase_							=   dim_out if dim_out is not None else dim

       if activation_fn == "gelu":
             lowerCamelCase_							=   GELU(A_						,							A_  )
       if activation_fn == "gelu-approximate":
             lowerCamelCase_							=   GELU(A_						,							A_						,							approximate='tanh'  )
       elif activation_fn == "geglu":
             lowerCamelCase_							=   GEGLU(A_						,							A_  )
       elif activation_fn == "geglu-approximate":
             lowerCamelCase_							=   ApproximateGELU(A_						,							A_  )

       lowerCamelCase_							=   nn.ModuleList([]  )
       # project in
       self.net.append(A_  )
       # project dropout
       self.net.append(nn.Dropout(A_  )  )
       # project out
       self.net.append(nn.Linear(A_						,							A_  )  )
       # FF as used in Vision Transformer, MLP-Mixer, etc. have a final dropout
       if final_dropout:
             self.net.append(nn.Dropout(A_  )  )





 def     a__			(    self :  int						,							A_ :  Optional[Any]  )       ->     int:

       """simple docstring"""






       for module in self.net:
             lowerCamelCase_							=   module(A_  )
       return hidden_states







class   A(						nn.Module       ):



 '''simple docstring'''


 def __init__(    self :  Tuple						,							A_ :  int						,							A_ :  int						,							A_ :  str = "none"  )       ->     Optional[int]:

       """simple docstring"""






       super().__init__()
       lowerCamelCase_							=   nn.Linear(A_						,							A_  )
       lowerCamelCase_							=   approximate

 def     a__			(    self :  str						,							A_ :  Tuple  )       ->     List[Any]:

       """simple docstring"""






       if gate.device.type != "mps":
             return F.gelu(A_						,							approximate=self.approximate  )
       # mps: gelu is not implemented for float16
       return F.gelu(gate.to(dtype=torch.floataa  )						,							approximate=self.approximate  ).to(dtype=gate.dtype  )





 def     a__			(    self :  Optional[int]						,							A_ :  Optional[Any]  )       ->     int:

       """simple docstring"""






       lowerCamelCase_							=   self.proj(A_  )
       lowerCamelCase_							=   self.gelu(A_  )
       return hidden_states







class   A(						nn.Module       ):



 '''simple docstring'''


 def __init__(    self :  Tuple						,							A_ :  int						,							A_ :  int  )       ->     List[Any]:

       """simple docstring"""






       super().__init__()
       lowerCamelCase_							=   nn.Linear(A_						,							dim_out * 2  )

 def     a__			(    self :  str						,							A_ :  Union[str, Any]  )       ->     List[str]:

       """simple docstring"""






       if gate.device.type != "mps":
             return F.gelu(A_  )
       # mps: gelu is not implemented for float16
       return F.gelu(gate.to(dtype=torch.floataa  )  ).to(dtype=gate.dtype  )





 def     a__			(    self :  Any						,							A_ :  Union[str, Any]  )       ->     int:

       """simple docstring"""






       lowerCamelCase_					,    lowerCamelCase_							=   self.proj(A_  ).chunk(2						,							dim=-1  )
       return hidden_states * self.gelu(A_  )







class   A(						nn.Module       ):



 '''simple docstring'''


 def __init__(    self :  Optional[int]						,							A_ :  int						,							A_ :  int  )       ->     Dict:

       """simple docstring"""






       super().__init__()
       lowerCamelCase_							=   nn.Linear(A_						,							A_  )





 def     a__			(    self :  List[str]						,							A_ :  int  )       ->     str:

       """simple docstring"""






       lowerCamelCase_							=   self.proj(A_  )
       return x * torch.sigmoid(1.702 * x  )







class   A(						nn.Module       ):



 '''simple docstring'''


 def __init__(    self :  str						,							A_ :  Optional[int]						,							A_ :  int  )       ->     Tuple:

       """simple docstring"""






       super().__init__()
       lowerCamelCase_							=   nn.Embedding(A_						,							A_  )
       lowerCamelCase_							=   nn.SiLU()
       lowerCamelCase_							=   nn.Linear(A_						,							embedding_dim * 2  )
       lowerCamelCase_							=   nn.LayerNorm(A_						,							elementwise_affine=A_  )





 def     a__			(    self :  List[str]						,							A_ :  List[Any]						,							A_ :  List[str]  )       ->     Dict:

       """simple docstring"""






       lowerCamelCase_							=   self.linear(self.silu(self.emb(A_  )  )  )
       lowerCamelCase_					,    lowerCamelCase_							=   torch.chunk(A_						,							2  )
       lowerCamelCase_							=   self.norm(A_  ) * (1 + scale) + shift
       return x







class   A(						nn.Module       ):



 '''simple docstring'''


 def __init__(    self :  Dict						,							A_ :  List[str]						,							A_ :  int  )       ->     str:

       """simple docstring"""






       super().__init__()

       lowerCamelCase_							=   CombinedTimestepLabelEmbeddings(A_						,							A_  )

       lowerCamelCase_							=   nn.SiLU()
       lowerCamelCase_							=   nn.Linear(A_						,							6 * embedding_dim						,							bias=A_  )
       lowerCamelCase_							=   nn.LayerNorm(A_						,							elementwise_affine=A_						,							eps=1E-6  )





 def     a__			(    self :  Optional[Any]						,							A_ :  int						,							A_ :  Optional[int]						,							A_ :  Optional[Any]						,							A_ :  Any=None  )       ->     Dict:

       """simple docstring"""






       lowerCamelCase_							=   self.linear(self.silu(self.emb(A_						,							A_						,							hidden_dtype=A_  )  )  )
       lowerCamelCase_					,    lowerCamelCase_					,    lowerCamelCase_					,    lowerCamelCase_					,    lowerCamelCase_					,    lowerCamelCase_							=   emb.chunk(6						,							dim=1  )
       lowerCamelCase_							=   self.norm(A_  ) * (1 + scale_msa[:, None]) + shift_msa[:, None]
       return x, gate_msa, shift_mlp, scale_mlp, gate_mlp







class   A(						nn.Module       ):



 '''simple docstring'''


 def __init__(    self :  Union[str, Any]						,							A_ :  int						,							A_ :  int						,							A_ :  int						,							A_ :  Optional[str] = None						,							A_ :  float = 1E-5  )       ->     Optional[int]:

       """simple docstring"""






       super().__init__()
       lowerCamelCase_							=   num_groups
       lowerCamelCase_							=   eps

       if act_fn is None:
             lowerCamelCase_							=   None
       else:
             lowerCamelCase_							=   get_activation(A_  )

       lowerCamelCase_							=   nn.Linear(A_						,							out_dim * 2  )





 def     a__			(    self :  Dict						,							A_ :  List[Any]						,							A_ :  Dict  )       ->     Dict:

       """simple docstring"""






       if self.act:
             lowerCamelCase_							=   self.act(A_  )
       lowerCamelCase_							=   self.linear(A_  )
       lowerCamelCase_							=   emb[:, :, None, None]
       lowerCamelCase_					,    lowerCamelCase_							=   emb.chunk(2						,							dim=1  )

       lowerCamelCase_							=   F.group_norm(A_						,							self.num_groups						,							eps=self.eps  )
       lowerCamelCase_							=   x * (1 + scale) + shift
       return x









from dataclasses import dataclass
from typing import Dict, Optional, Union

import torch
import torch.nn.functional as F
from torch import nn

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from .attention import BasicTransformerBlock
from .attention_processor import AttentionProcessor, AttnProcessor
from .embeddings import TimestepEmbedding, Timesteps
from .modeling_utils import ModelMixin







@dataclass
class   A(						UpperCamelCase       ):



 '''simple docstring'''


 UpperCamelCase						       =						42







class   A(						UpperCamelCase							,				UpperCamelCase       ):



 '''simple docstring'''


 @register_to_config
 def __init__(    self :  Tuple						,							A_ :  int = 32						,							A_ :  int = 64						,							A_ :  int = 20						,							A_ :  int = 768						,							A_ :  Optional[Any]=77						,							A_ :  Optional[int]=4						,							A_ :  float = 0.0						,							A_ :  str = "silu"						,							A_ :  Optional[str] = None						,							A_ :  Optional[str] = None						,							A_ :  Optional[str] = "linear"						,							A_ :  Optional[str] = "prd"						,							A_ :  Optional[int] = None						,							A_ :  Optional[int] = None						,							A_ :  Optional[int] = None						,							)       ->     List[Any]:

       """simple docstring"""






       super().__init__()
       lowerCamelCase_							=   num_attention_heads
       lowerCamelCase_							=   attention_head_dim
       lowerCamelCase_							=   num_attention_heads * attention_head_dim
       lowerCamelCase_							=   additional_embeddings

       lowerCamelCase_							=   time_embed_dim or inner_dim
       lowerCamelCase_							=   embedding_proj_dim or embedding_dim
       lowerCamelCase_							=   clip_embed_dim or embedding_dim

       lowerCamelCase_							=   Timesteps(A_						,							A_						,							0  )
       lowerCamelCase_							=   TimestepEmbedding(A_						,							A_						,							out_dim=A_						,							act_fn=A_  )

       lowerCamelCase_							=   nn.Linear(A_						,							A_  )

       if embedding_proj_norm_type is None:
             lowerCamelCase_							=   None
       elif embedding_proj_norm_type == "layer":
             lowerCamelCase_							=   nn.LayerNorm(A_  )
       else:
             raise ValueError(f"""unsupported embedding_proj_norm_type: {embedding_proj_norm_type}"""  )

       lowerCamelCase_							=   nn.Linear(A_						,							A_  )

       if encoder_hid_proj_type is None:
             lowerCamelCase_							=   None
       elif encoder_hid_proj_type == "linear":
             lowerCamelCase_							=   nn.Linear(A_						,							A_  )
       else:
             raise ValueError(f"""unsupported encoder_hid_proj_type: {encoder_hid_proj_type}"""  )

       lowerCamelCase_							=   nn.Parameter(torch.zeros(1						,							num_embeddings + additional_embeddings						,							A_  )  )

       if added_emb_type == "prd":
             lowerCamelCase_							=   nn.Parameter(torch.zeros(1						,							1						,							A_  )  )
       elif added_emb_type is None:
             lowerCamelCase_							=   None
       else:
             raise ValueError(
                 f"""`added_emb_type`: {added_emb_type} is not supported. Make sure to choose one of `'prd'` or `None`."""  )

       lowerCamelCase_							=   nn.ModuleList(
           [
               BasicTransformerBlock(
                   A_						,							A_						,							A_						,							dropout=A_						,							activation_fn='gelu'						,							attention_bias=A_						,							)
               for d in range(A_  )
           ]  )

       if norm_in_type == "layer":
             lowerCamelCase_							=   nn.LayerNorm(A_  )
       elif norm_in_type is None:
             lowerCamelCase_							=   None
       else:
             raise ValueError(f"""Unsupported norm_in_type: {norm_in_type}."""  )

       lowerCamelCase_							=   nn.LayerNorm(A_  )

       lowerCamelCase_							=   nn.Linear(A_						,							A_  )

       lowerCamelCase_							=   torch.full(
           [num_embeddings + additional_embeddings, num_embeddings + additional_embeddings]						,							-10000.0  )
       causal_attention_mask.triu_(1  )
       lowerCamelCase_							=   causal_attention_mask[None, ...]
       self.register_buffer('causal_attention_mask'						,							A_						,							persistent=A_  )

       lowerCamelCase_							=   nn.Parameter(torch.zeros(1						,							A_  )  )
       lowerCamelCase_							=   nn.Parameter(torch.zeros(1						,							A_  )  )

 @property
 # Copied from diffusers.models.unet_2d_condition.UNet2DConditionModel.attn_processors
 def     a__			(    self :  str  )       ->     Dict[str, AttentionProcessor]:

       """simple docstring"""






       lowerCamelCase_							=   {}

       def fn_recursive_add_processors(A_ :  str						,							A_ :  torch.nn.Module						,							A_ :  Dict[str, AttentionProcessor]  ):
             if hasattr(A_						,							'set_processor'  ):
                   lowerCamelCase_							=   module.processor

             for sub_name, child in module.named_children():
                   fn_recursive_add_processors(f"""{name}.{sub_name}"""						,							A_						,							A_  )

             return processors

       for name, module in self.named_children():
             fn_recursive_add_processors(A_						,							A_						,							A_  )

       return processors

 def     a__			(    self :  List[Any]						,							A_ :  Union[AttentionProcessor, Dict[str, AttentionProcessor]]  )       ->     Dict:

       """simple docstring"""






       lowerCamelCase_							=   len(self.attn_processors.keys()  )

       if isinstance(A_						,							A_  ) and len(A_  ) != count:
             raise ValueError(
                 f"""A dict of processors was passed, but the number of processors {len(A_  )} does not match the"""
                 f""" number of attention layers: {count}. Please make sure to pass {count} processor classes."""  )

       def fn_recursive_attn_processor(A_ :  str						,							A_ :  torch.nn.Module						,							A_ :  Union[str, Any]  ):
             if hasattr(A_						,							'set_processor'  ):
                   if not isinstance(A_						,							A_  ):
                         module.set_processor(A_  )
                   else:
                         module.set_processor(processor.pop(f"""{name}.processor"""  )  )

             for sub_name, child in module.named_children():
                   fn_recursive_attn_processor(f"""{name}.{sub_name}"""						,							A_						,							A_  )

       for name, module in self.named_children():
             fn_recursive_attn_processor(A_						,							A_						,							A_  )

 def     a__			(    self :  List[Any]  )       ->     List[Any]:

       """simple docstring"""






       self.set_attn_processor(AttnProcessor()  )

 def     a__			(    self :  Dict						,							A_ :  List[Any]						,							A_ :  Union[torch.Tensor, float, int]						,							A_ :  torch.FloatTensor						,							A_ :  Optional[torch.FloatTensor] = None						,							A_ :  Optional[torch.BoolTensor] = None						,							A_ :  bool = True						,							)       ->     str:

       """simple docstring"""






       lowerCamelCase_							=   hidden_states.shape[0]

       lowerCamelCase_							=   timestep
       if not torch.is_tensor(A_  ):
             lowerCamelCase_							=   torch.tensor([timesteps]						,							dtype=torch.long						,							device=hidden_states.device  )
       elif torch.is_tensor(A_  ) and len(timesteps.shape  ) == 0:
             lowerCamelCase_							=   timesteps[None].to(hidden_states.device  )

       # broadcast to batch dimension in a way that's compatible with ONNX/Core ML
       lowerCamelCase_							=   timesteps * torch.ones(A_						,							dtype=timesteps.dtype						,							device=timesteps.device  )

       lowerCamelCase_							=   self.time_proj(A_  )

       # timesteps does not contain any weights and will always return f32 tensors
       # but time_embedding might be fp16, so we need to cast here.
       lowerCamelCase_							=   timesteps_projected.to(dtype=self.dtype  )
       lowerCamelCase_							=   self.time_embedding(A_  )

       if self.embedding_proj_norm is not None:
             lowerCamelCase_							=   self.embedding_proj_norm(A_  )

       lowerCamelCase_							=   self.embedding_proj(A_  )
       if self.encoder_hidden_states_proj is not None and encoder_hidden_states is not None:
             lowerCamelCase_							=   self.encoder_hidden_states_proj(A_  )
       elif self.encoder_hidden_states_proj is not None and encoder_hidden_states is None:
             raise ValueError('`encoder_hidden_states_proj` requires `encoder_hidden_states` to be set'  )

       lowerCamelCase_							=   self.proj_in(A_  )

       lowerCamelCase_							=   self.positional_embedding.to(hidden_states.dtype  )

       lowerCamelCase_							=   []
       lowerCamelCase_							=   0

       if encoder_hidden_states is not None:
             additional_embeds.append(A_  )
             additional_embeddings_len += encoder_hidden_states.shape[1]

       if len(proj_embeddings.shape  ) == 2:
             lowerCamelCase_							=   proj_embeddings[:, None, :]

       if len(hidden_states.shape  ) == 2:
             lowerCamelCase_							=   hidden_states[:, None, :]

       lowerCamelCase_							=   additional_embeds + [
           proj_embeddings,
           time_embeddings[:, None, :],
           hidden_states,
       ]

       if self.prd_embedding is not None:
             lowerCamelCase_							=   self.prd_embedding.to(hidden_states.dtype  ).expand(A_						,							-1						,							-1  )
             additional_embeds.append(A_  )

       lowerCamelCase_							=   torch.cat(
           A_						,							dim=1						,							)

       # Allow positional_embedding to not include the `addtional_embeddings` and instead pad it with zeros for these additional tokens
       lowerCamelCase_							=   additional_embeddings_len + proj_embeddings.shape[1] + 1
       if positional_embeddings.shape[1] < hidden_states.shape[1]:
             lowerCamelCase_							=   F.pad(
                 A_						,							(
                     0,
                     0,
                     additional_embeddings_len,
                     self.prd_embedding.shape[1] if self.prd_embedding is not None else 0,
                 )						,							value=0.0						,							)

       lowerCamelCase_							=   hidden_states + positional_embeddings

       if attention_mask is not None:
             lowerCamelCase_							=   (1 - attention_mask.to(hidden_states.dtype  )) * -10000.0
             lowerCamelCase_							=   F.pad(A_						,							(0, self.additional_embeddings)						,							value=0.0  )
             lowerCamelCase_							=   (attention_mask[:, None, :] + self.causal_attention_mask).to(hidden_states.dtype  )
             lowerCamelCase_							=   attention_mask.repeat_interleave(self.config.num_attention_heads						,							dim=0  )

       if self.norm_in is not None:
             lowerCamelCase_							=   self.norm_in(A_  )

       for block in self.transformer_blocks:
             lowerCamelCase_							=   block(A_						,							attention_mask=A_  )

       lowerCamelCase_							=   self.norm_out(A_  )

       if self.prd_embedding is not None:
             lowerCamelCase_							=   hidden_states[:, -1]
       else:
             lowerCamelCase_							=   hidden_states[:, additional_embeddings_len:]

       lowerCamelCase_							=   self.proj_to_clip_embeddings(A_  )

       if not return_dict:
             return (predicted_image_embedding,)

       return PriorTransformerOutput(predicted_image_embedding=A_  )





 def     a__			(    self :  Tuple						,							A_ :  List[Any]  )       ->     Any:

       """simple docstring"""






       lowerCamelCase_							=   (prior_latents * self.clip_std) + self.clip_mean
       return prior_latents



