### Up block This combines `ResidualBlock` and `AttentionBlock`. These are used in the second half of U-Net at each resolution.
| 132 | |
| 133 | |
| 134 | class UpBlock(nn.Module): |
| 135 | """ |
| 136 | ### Up block |
| 137 | This combines `ResidualBlock` and `AttentionBlock`. These are used in the second half of U-Net at each resolution. |
| 138 | """ |
| 139 | |
| 140 | def __init__(self, in_channels: int, out_channels: int, time_channels: int, is_noise: bool = True): |
| 141 | super().__init__() |
| 142 | # The input has `in_channels + out_channels` because we concatenate the output of the same resolution |
| 143 | # from the first half of the U-Net |
| 144 | self.res = ResidualBlock(in_channels + out_channels, out_channels, time_channels, is_noise=is_noise) |
| 145 | |
| 146 | def forward(self, x: torch.Tensor, t: torch.Tensor): |
| 147 | x = self.res(x, t) |
| 148 | return x |
| 149 | |
| 150 | |
| 151 | class MiddleBlock(nn.Module): |