class_docstr: ### Up block
  
  This combines `ResidualBlock` and `AttentionBlock`. These are used in the second half of U-Net at each resolution.
class_docstr_tok: ["#","#","#","Up","block","This","combines","`","ResidualBlock","`","and","`","AttentionBlock","`",".","These","are","used","in","the","second","half","of","U-Net","at","each","resolution","."]
code: def __init__(
      self,
      in_channels: int,
      out_channels: int,
      time_channels: int,
      has_attn: bool,
  ):
      super().__init__()
      # The input has `in_channels + out_channels` because we concatenate the output of the same resolution
      # from the first half of the U-Net
      self.res = ResidualBlock(
          in_channels + out_channels, out_channels, time_channels
      )
      if has_attn:
          self.attn = AttentionBlock(out_channels)
      else:
          self.attn = nn.Identity()
  
imports: import math
  from typing import Optional, Tuple, Union, List
  import torch
  from torch import nn
  from labml_helpers.module import Module
label_desc: Use image node_id 1 to create a new UpBlock object from inherited base classes: Module with example: obj = UpBlock(in_channels, out_channels, time_channels, has_attn)