code: def forward(
      self,
      sample: paddle.Tensor,
      timestep: Union[paddle.Tensor, float, int],
      encoder_hidden_states: paddle.Tensor,
  ) -> Dict[str, paddle.Tensor]:
      # 0. center input if necessary
      if self.config.center_input_sample:
          sample = 2 * sample - 1.0
  
      # 1. time
      timesteps = timestep
      if not paddle.is_tensor(timesteps):
          timesteps = paddle.to_tensor([timesteps], dtype="int64")
      elif paddle.is_tensor(timesteps) and len(timesteps.shape) == 0:
          timesteps = timesteps[None]
  
      # broadcast to batch dimension
      timesteps = paddle.broadcast_to(timesteps, [sample.shape[0]])
  
      t_emb = self.time_proj(timesteps)
      emb = self.time_embedding(t_emb)
  
      # 2. pre-process
      sample = self.conv_in(sample)
  
      # 3. down
      down_block_res_samples = (sample,)
      for downsample_block in self.down_blocks:
          if (
              hasattr(downsample_block, "attentions")
              and downsample_block.attentions is not None
          ):
              sample, res_samples = downsample_block(
                  hidden_states=sample,
                  temb=emb,
                  encoder_hidden_states=encoder_hidden_states,
              )
          else:
              sample, res_samples = downsample_block(
                  hidden_states=sample, temb=emb
              )
  
          down_block_res_samples += res_samples
  
      # 4. mid
      sample = self.mid_block(
          sample, emb, encoder_hidden_states=encoder_hidden_states
      )
  
      # 5. up
      for upsample_block in self.up_blocks:
          res_samples = down_block_res_samples[
              -len(upsample_block.resnets) :
          ]
          down_block_res_samples = down_block_res_samples[
              : -len(upsample_block.resnets)
          ]
  
          if (
              hasattr(upsample_block, "attentions")
              and upsample_block.attentions is not None
          ):
              sample = upsample_block(
                  hidden_states=sample,
                  temb=emb,
                  res_hidden_states_tuple=res_samples,
                  encoder_hidden_states=encoder_hidden_states,
              )
          else:
              sample = upsample_block(
                  hidden_states=sample,
                  temb=emb,
                  res_hidden_states_tuple=res_samples,
              )
  
      # 6. post-process
      # make sure hidden states is in float32
      # when running in half-precision
      sample = self.conv_norm_out(sample.astype("float32")).astype(
          sample.dtype
      )
      sample = self.conv_act(sample)
      sample = self.conv_out(sample)
  
      output = {"sample": sample}
  
      return output
  
file_path: PaddleHub/modules/image/text_to_image/stable_diffusion_waifu/diffusers/models/unet_2d_condition.py
imports: from typing import Dict
  from typing import Union
  import paddle
  import paddle.nn
  from ..configuration_utils import ConfigMixin
  from ..configuration_utils import register_to_config
  from .embeddings import TimestepEmbedding
  from .embeddings import Timesteps
  from .unet_blocks import get_down_block
  from .unet_blocks import get_up_block
  from .unet_blocks import UNetMidBlock2DCrossAttn
label_desc: Use image node_id 2 for calling the UNet2DConditionModel obj's underlying member method code with example usage: obj.forward(sample, timestep, encoder_hidden_states) and returns: output