class_docstr: A 1D UNet model that takes a noisy sample 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).
  
  Parameters:
      sample_size (`int`, *optional*): Default length of sample. Should be adaptable at runtime.
      in_channels (`int`, *optional*, defaults to 2): Number of channels in the input sample.
      out_channels (`int`, *optional*, defaults to 2): Number of channels in the output.
      extra_in_channels (`int`, *optional*, defaults to 0):
          Number of additional channels to be added to the input of the first down block. Useful for cases where the
          input data has more channels than what the model was initially designed for.
      time_embedding_type (`str`, *optional*, defaults to `"fourier"`): Type of time embedding to use.
      freq_shift (`float`, *optional*, defaults to 0.0): Frequency shift for Fourier time embedding.
      flip_sin_to_cos (`bool`, *optional*, defaults to `False`):
          Whether to flip sin to cos for Fourier time embedding.
      down_block_types (`Tuple[str]`, *optional*, defaults to `("DownBlock1DNoSkip", "DownBlock1D", "AttnDownBlock1D")`):
          Tuple of downsample block types.
      up_block_types (`Tuple[str]`, *optional*, defaults to `("AttnUpBlock1D", "UpBlock1D", "UpBlock1DNoSkip")`):
          Tuple of upsample block types.
      block_out_channels (`Tuple[int]`, *optional*, defaults to `(32, 32, 64)`):
          Tuple of block output channels.
      mid_block_type (`str`, *optional*, defaults to `"UNetMidBlock1D"`): Block type for middle of UNet.
      out_block_type (`str`, *optional*, defaults to `None`): Optional output processing block of UNet.
      act_fn (`str`, *optional*, defaults to `None`): Optional activation function in UNet blocks.
      norm_num_groups (`int`, *optional*, defaults to 8): The number of groups for normalization.
      layers_per_block (`int`, *optional*, defaults to 1): The number of layers per block.
      downsample_each_block (`int`, *optional*, defaults to `False`):
          Experimental feature for using a UNet without upsampling.
code: def __init__(
      self,
      sample_size: int = 65536,
      sample_rate: Optional[int] = None,
      in_channels: int = 2,
      out_channels: int = 2,
      extra_in_channels: int = 0,
      time_embedding_type: str = "fourier",
      flip_sin_to_cos: bool = True,
      use_timestep_embedding: bool = False,
      freq_shift: float = 0.0,
      down_block_types: Tuple[str] = (
          "DownBlock1DNoSkip",
          "DownBlock1D",
          "AttnDownBlock1D",
      ),
      up_block_types: Tuple[str] = (
          "AttnUpBlock1D",
          "UpBlock1D",
          "UpBlock1DNoSkip",
      ),
      mid_block_type: Tuple[str] = "UNetMidBlock1D",
      out_block_type: str = None,
      block_out_channels: Tuple[int] = (32, 32, 64),
      act_fn: str = None,
      norm_num_groups: int = 8,
      layers_per_block: int = 1,
      downsample_each_block: bool = False,
  ):
      super().__init__()
      self.sample_size = sample_size
  
      # time
      if time_embedding_type == "fourier":
          self.time_proj = GaussianFourierProjection(
              embedding_size=8,
              set_W_to_weight=False,
              log=False,
              flip_sin_to_cos=flip_sin_to_cos,
          )
          timestep_input_dim = 2 * block_out_channels[0]
      elif time_embedding_type == "positional":
          self.time_proj = Timesteps(
              block_out_channels[0],
              flip_sin_to_cos=flip_sin_to_cos,
              downscale_freq_shift=freq_shift,
          )
          timestep_input_dim = block_out_channels[0]
  
      if use_timestep_embedding:
          time_embed_dim = block_out_channels[0] * 4
          self.time_mlp = TimestepEmbedding(
              in_channels=timestep_input_dim,
              time_embed_dim=time_embed_dim,
              act_fn=act_fn,
              out_dim=block_out_channels[0],
          )
  
      self.down_blocks = nn.ModuleList([])
      self.mid_block = None
      self.up_blocks = nn.ModuleList([])
      self.out_block = None
  
      # down
      output_channel = in_channels
      for i, down_block_type in enumerate(down_block_types):
          input_channel = output_channel
          output_channel = block_out_channels[i]
  
          if i == 0:
              input_channel += extra_in_channels
  
          is_final_block = i == len(block_out_channels) - 1
  
          down_block = get_down_block(
              down_block_type,
              num_layers=layers_per_block,
              in_channels=input_channel,
              out_channels=output_channel,
              temb_channels=block_out_channels[0],
              add_downsample=not is_final_block
              or downsample_each_block,
          )
          self.down_blocks.append(down_block)
  
      # mid
      self.mid_block = get_mid_block(
          mid_block_type,
          in_channels=block_out_channels[-1],
          mid_channels=block_out_channels[-1],
          out_channels=block_out_channels[-1],
          embed_dim=block_out_channels[0],
          num_layers=layers_per_block,
          add_downsample=downsample_each_block,
      )
  
      # up
      reversed_block_out_channels = list(reversed(block_out_channels))
      output_channel = reversed_block_out_channels[0]
      if out_block_type is None:
          final_upsample_channels = out_channels
      else:
          final_upsample_channels = block_out_channels[0]
  
      for i, up_block_type in enumerate(up_block_types):
          prev_output_channel = output_channel
          output_channel = (
              reversed_block_out_channels[i + 1]
              if i < len(up_block_types) - 1
              else final_upsample_channels
          )
  
          is_final_block = i == len(block_out_channels) - 1
  
          up_block = get_up_block(
              up_block_type,
              num_layers=layers_per_block,
              in_channels=prev_output_channel,
              out_channels=output_channel,
              temb_channels=block_out_channels[0],
              add_upsample=not is_final_block,
          )
          self.up_blocks.append(up_block)
          prev_output_channel = output_channel
  
      # out
      num_groups_out = (
          norm_num_groups
          if norm_num_groups is not None
          else min(block_out_channels[0] // 4, 32)
      )
      self.out_block = get_out_block(
          out_block_type=out_block_type,
          num_groups_out=num_groups_out,
          embed_dim=block_out_channels[0],
          out_channels=out_channels,
          act_fn=act_fn,
          fc_dim=block_out_channels[-1] // 4,
      )
  
file_path: diffusers/src/diffusers/models/unet_1d.py
imports: from dataclasses import dataclass
  from typing import Optional, Tuple, Union
  import torch
  import torch.nn
  from ..configuration_utils import ConfigMixin, register_to_config
  from ..utils import BaseOutput
  from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps
  from .modeling_utils import ModelMixin
  from .unet_1d_blocks import get_down_block, get_mid_block, get_out_block, get_up_block
label_desc: Use image node_id 1 to create a new UNet1DModel object from inherited base classes: ModelMixin, ConfigMixin with example: obj = UNet1DModel(sample_size, sample_rate, in_channels, out_channels, extra_in_channels, time_embedding_type, flip_sin_to_cos, use_timestep_embedding, freq_shift, down_block_types, up_block_types, mid_block_type, out_block_type, block_out_channels, act_fn, norm_num_groups, layers_per_block, downsample_each_block)