code: def __init__(
      self,
      in_planes: int,
      down_planes: int,
      child: nn.Module,
      out_planes: Optional[int] = None,
      top: bool = False,
      clip_upsample: bool = False,
      norm_type: str = "identity",
  ):
      super().__init__()
      self.in_planes = in_planes
      self.down_planes = down_planes
      if out_planes is None:
          out_planes = in_planes
      self.out_planes = out_planes
      self.child = child
      self.clip_upsample = clip_upsample
      self.norm_type = norm_type
  
      use_bias = True
      if norm_type == "batch":
          use_bias = False
  
      norm_layer = partial(build_norm_layer, norm_type=norm_type)
      conv_norm = partial(apply_conv_norm, norm_type=norm_type)
  
      self.left_block = nn.Sequential(
          nn.Identity() if top else norm_layer(in_planes),
          nn.Identity()
          if top
          else nn.LeakyReLU(negative_slope=0.2, inplace=True),
          conv_norm(
              _conv(
                  in_planes=in_planes,
                  out_planes=down_planes,
                  bias=use_bias,
              )
          ),
          norm_layer(down_planes),
          nn.LeakyReLU(negative_slope=0.2, inplace=True),
          conv_norm(
              _conv(in_planes=down_planes, out_planes=down_planes)
          ),
          nn.AvgPool2d(2),
      )
      if in_planes != down_planes:
          left_shortcut_conv = conv_norm(
              _conv(
                  in_planes=in_planes,
                  out_planes=down_planes,
                  kernel_size=1,
                  padding=0,
                  bias=True,
              )
          )
      else:
          left_shortcut_conv = nn.Identity()
  
      self.left_shortcut = nn.Sequential(
          left_shortcut_conv,
          nn.AvgPool2d(2),
      )
  
      self.right_block: nn.Module
      self.right_shortcut: Union[nn.Module, Callable]
      if clip_upsample is True:
          self.right_block = nn.Identity()
          self.right_shortcut = lambda x: torch.tensor(0.0)
      else:
          self.right_block = nn.Sequential(
              norm_layer(down_planes),
              nn.LeakyReLU(negative_slope=0.2, inplace=True),
              nn.Upsample(scale_factor=2),
              conv_norm(
                  _conv(
                      in_planes=down_planes,
                      out_planes=out_planes,
                      bias=use_bias,
                  )
              ),
              norm_layer(out_planes),
              nn.LeakyReLU(negative_slope=0.2, inplace=True),
              conv_norm(
                  _conv(in_planes=out_planes, out_planes=out_planes)
              ),
          )
          if down_planes != out_planes:
              right_shortcut_conv = conv_norm(
                  _conv(
                      in_planes=down_planes,
                      out_planes=out_planes,
                      kernel_size=1,
                      padding=0,
                      bias=True,
                  )
              )
          else:
              right_shortcut_conv = nn.Identity()
  
          self.right_shortcut = nn.Sequential(
              right_shortcut_conv, nn.Upsample(scale_factor=2)
          )
  
imports: import math
  from functools import partial
  from typing import Callable, List, Optional, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from torch.nn.utils.parametrizations import spectral_norm
  from ._discriminator import Discriminator
label_desc: Use image node_id 1 to create a new _UnetLevel object from inherited base classes: nn with example: obj = _UnetLevel(in_planes, down_planes, child, out_planes, top, clip_upsample, norm_type)