code: def forward(self, z, latent_embeds=None):
      sample = z
      sample = self.conv_in(sample)
  
      upscale_dtype = next(iter(self.up_blocks.parameters())).dtype
      if self.training and self.gradient_checkpointing:
  
          def create_custom_forward(module):
              def custom_forward(*inputs):
                  return module(*inputs)
  
              return custom_forward
  
          if is_torch_version(">=", "1.11.0"):
              # middle
              sample = torch.utils.checkpoint.checkpoint(
                  create_custom_forward(self.mid_block),
                  sample,
                  latent_embeds,
                  use_reentrant=False,
              )
              sample = sample.to(upscale_dtype)
  
              # up
              for up_block in self.up_blocks:
                  sample = torch.utils.checkpoint.checkpoint(
                      create_custom_forward(up_block),
                      sample,
                      latent_embeds,
                      use_reentrant=False,
                  )
          else:
              # middle
              sample = torch.utils.checkpoint.checkpoint(
                  create_custom_forward(self.mid_block),
                  sample,
                  latent_embeds,
              )
              sample = sample.to(upscale_dtype)
  
              # up
              for up_block in self.up_blocks:
                  sample = torch.utils.checkpoint.checkpoint(
                      create_custom_forward(up_block),
                      sample,
                      latent_embeds,
                  )
      else:
          # middle
          sample = self.mid_block(sample, latent_embeds)
          sample = sample.to(upscale_dtype)
  
          # up
          for up_block in self.up_blocks:
              sample = up_block(sample, latent_embeds)
  
      # post-process
      if latent_embeds is None:
          sample = self.conv_norm_out(sample)
      else:
          sample = self.conv_norm_out(sample, latent_embeds)
      sample = self.conv_act(sample)
      sample = self.conv_out(sample)
  
      return sample
  
imports: from dataclasses import dataclass
  from typing import Optional
  import numpy
  import torch
  import torch.nn
  from ..utils import BaseOutput, is_torch_version
  from ..utils.torch_utils import randn_tensor
  from .activations import get_activation
  from .attention_processor import SpatialNorm
  from .unet_2d_blocks import AutoencoderTinyBlock, UNetMidBlock2D, get_down_block, get_up_block
label_desc: Use image node_id 2 for calling the Decoder obj's underlying member method code with example usage: obj.forward(z, latent_embeds) and returns: sample, custom_forward, module