class_docstr: A modified conditional 2D UNet model that takes a noisy sample, conditional state, and a timestep and returns a
  sample shaped output.
  
  This model inherits from [`ModelMixin`]. Check the superclass documentation for it's generic methods implemented
  for all models (such as downloading or saving).
code: def save_motion_modules(
      self,
      save_directory: str,
      is_main_process: bool = True,
      safe_serialization: bool = True,
      variant: Optional[str] = None,
      push_to_hub: bool = False,
      **kwargs,
  ) -> None:
      state_dict = self.state_dict()
  
      # Extract all motion modules
      motion_state_dict = {}
      for k, v in state_dict.items():
          if "motion_modules" in k:
              motion_state_dict[k] = v
  
      adapter = MotionAdapter(
          block_out_channels=self.config["block_out_channels"],
          motion_layers_per_block=self.config["layers_per_block"],
          motion_norm_num_groups=self.config["norm_num_groups"],
          motion_num_attention_heads=self.config[
              "motion_num_attention_heads"
          ],
          motion_max_seq_length=self.config["motion_max_seq_length"],
          use_motion_mid_block=self.config["use_motion_mid_block"],
      )
      adapter.load_state_dict(motion_state_dict)
      adapter.save_pretrained(
          save_directory=save_directory,
          is_main_process=is_main_process,
          safe_serialization=safe_serialization,
          variant=variant,
          push_to_hub=push_to_hub,
          **kwargs,
      )
  
imports: from typing import Any, Dict, Optional, Tuple, Union
  import torch
  import torch.nn
  import torch.utils.checkpoint
  from ..configuration_utils import ConfigMixin, register_to_config
  from ..loaders import UNet2DConditionLoadersMixin
  from ..utils import logging
  from .attention_processor import ADDED_KV_ATTENTION_PROCESSORS, CROSS_ATTENTION_PROCESSORS, AttentionProcessor, AttnAddedKVProcessor, AttnProcessor
  from .embeddings import TimestepEmbedding, Timesteps
  from .modeling_utils import ModelMixin
  from .transformer_temporal import TransformerTemporalModel
  from .unet_2d_blocks import UNetMidBlock2DCrossAttn
  from .unet_2d_condition import UNet2DConditionModel
  from .unet_3d_blocks import CrossAttnDownBlockMotion, CrossAttnUpBlockMotion, DownBlockMotion, UNetMidBlockCrossAttnMotion, UpBlockMotion, get_down_block, get_up_block
  from .unet_3d_condition import UNet3DConditionOutput
label_desc: Use image node_id 5 for calling the UNetMotionModel obj's underlying member method code with example usage: obj.save_motion_modules(save_directory, is_main_process, safe_serialization, variant, push_to_hub) without return types