r""" The [`NestedUNet2DConditionModel`] forward method. Args: sample (`torch.Tensor`): The noisy input tensor with the following shape `(batch, channel, height, width)`. timestep (`torch.Tensor` or `float` or `int`): The number of timesteps to
(
self,
sample: torch.Tensor,
timestep: Union[torch.Tensor, float, int],
encoder_hidden_states: torch.Tensor,
cond_emb: Optional[torch.Tensor] = None,
from_nested: bool = False,
class_labels: Optional[torch.Tensor] = None,
timestep_cond: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
cross_attention_kwargs: Optional[Dict[str, Any]] = None,
added_cond_kwargs: Optional[Dict[str, torch.Tensor]] = None,
down_block_additional_residuals: Optional[Tuple[torch.Tensor]] = None,
mid_block_additional_residual: Optional[torch.Tensor] = None,
down_intrablock_additional_residuals: Optional[Tuple[torch.Tensor]] = None,
encoder_attention_mask: Optional[torch.Tensor] = None,
return_dict: bool = True,
)
| 3307 | return "nested_unet" |
| 3308 | |
| 3309 | def forward( |
| 3310 | self, |
| 3311 | sample: torch.Tensor, |
| 3312 | timestep: Union[torch.Tensor, float, int], |
| 3313 | encoder_hidden_states: torch.Tensor, |
| 3314 | cond_emb: Optional[torch.Tensor] = None, |
| 3315 | from_nested: bool = False, |
| 3316 | class_labels: Optional[torch.Tensor] = None, |
| 3317 | timestep_cond: Optional[torch.Tensor] = None, |
| 3318 | attention_mask: Optional[torch.Tensor] = None, |
| 3319 | cross_attention_kwargs: Optional[Dict[str, Any]] = None, |
| 3320 | added_cond_kwargs: Optional[Dict[str, torch.Tensor]] = None, |
| 3321 | down_block_additional_residuals: Optional[Tuple[torch.Tensor]] = None, |
| 3322 | mid_block_additional_residual: Optional[torch.Tensor] = None, |
| 3323 | down_intrablock_additional_residuals: Optional[Tuple[torch.Tensor]] = None, |
| 3324 | encoder_attention_mask: Optional[torch.Tensor] = None, |
| 3325 | return_dict: bool = True, |
| 3326 | ) -> Union[MatryoshkaUNet2DConditionOutput, Tuple]: |
| 3327 | r""" |
| 3328 | The [`NestedUNet2DConditionModel`] forward method. |
| 3329 | |
| 3330 | Args: |
| 3331 | sample (`torch.Tensor`): |
| 3332 | The noisy input tensor with the following shape `(batch, channel, height, width)`. |
| 3333 | timestep (`torch.Tensor` or `float` or `int`): The number of timesteps to denoise an input. |
| 3334 | encoder_hidden_states (`torch.Tensor`): |
| 3335 | The encoder hidden states with shape `(batch, sequence_length, feature_dim)`. |
| 3336 | class_labels (`torch.Tensor`, *optional*, defaults to `None`): |
| 3337 | Optional class labels for conditioning. Their embeddings will be summed with the timestep embeddings. |
| 3338 | timestep_cond: (`torch.Tensor`, *optional*, defaults to `None`): |
| 3339 | Conditional embeddings for timestep. If provided, the embeddings will be summed with the samples passed |
| 3340 | through the `self.time_embedding` layer to obtain the timestep embeddings. |
| 3341 | attention_mask (`torch.Tensor`, *optional*, defaults to `None`): |
| 3342 | An attention mask of shape `(batch, key_tokens)` is applied to `encoder_hidden_states`. If `1` the mask |
| 3343 | is kept, otherwise if `0` it is discarded. Mask will be converted into a bias, which adds large |
| 3344 | negative values to the attention scores corresponding to "discard" tokens. |
| 3345 | cross_attention_kwargs (`dict`, *optional*): |
| 3346 | A kwargs dictionary that if specified is passed along to the `AttentionProcessor` as defined under |
| 3347 | `self.processor` in |
| 3348 | [diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py). |
| 3349 | added_cond_kwargs: (`dict`, *optional*): |
| 3350 | A kwargs dictionary containing additional embeddings that if specified are added to the embeddings that |
| 3351 | are passed along to the UNet blocks. |
| 3352 | down_block_additional_residuals: (`tuple` of `torch.Tensor`, *optional*): |
| 3353 | A tuple of tensors that if specified are added to the residuals of down unet blocks. |
| 3354 | mid_block_additional_residual: (`torch.Tensor`, *optional*): |
| 3355 | A tensor that if specified is added to the residual of the middle unet block. |
| 3356 | down_intrablock_additional_residuals (`tuple` of `torch.Tensor`, *optional*): |
| 3357 | additional residuals to be added within UNet down blocks, for example from T2I-Adapter side model(s) |
| 3358 | encoder_attention_mask (`torch.Tensor`): |
| 3359 | A cross-attention mask of shape `(batch, sequence_length)` is applied to `encoder_hidden_states`. If |
| 3360 | `True` the mask is kept, otherwise if `False` it is discarded. Mask will be converted into a bias, |
| 3361 | which adds large negative values to the attention scores corresponding to "discard" tokens. |
| 3362 | return_dict (`bool`, *optional*, defaults to `True`): |
| 3363 | Whether or not to return a [`~NestedUNet2DConditionOutput`] instead of a plain |
| 3364 | tuple. |
| 3365 | |
| 3366 | Returns: |
nothing calls this directly
no test coverage detected