class UpConcat_ATT(nn.Module):
def init(self, in_feat, out_feat):
super(UpConcat_ATT, self).init()
    self.W_x = nn.Sequential(
        nn.Conv2d(in_feat, out_feat, kernel_size=1, stride=2, padding=0, bias=True),
        nn.BatchNorm2d(out_feat)
    )

    self.W_g = nn.Sequential(
        nn.Conv2d(in_feat, out_feat, kernel_size=1, stride=1, padding=0, bias=True),
        nn.BatchNorm2d(out_feat)
    )

    self.relu = nn.ReLU(inplace=True)

    self.upsample = nn.Sequential(
        nn.ConvTranspose2d(in_feat, out_feat, kernel_size=3, padding=1, stride=1, dilation=1, output_padding=0),
        nn.Upsample(scale_factor=2, mode="bilinear", align_corners=True)
    )


def forward(self, x, g):
    x_conv = self.W_x(x)
    g_conv = self.W_g(g)

    summed = x_conv + g_conv
    summed_relu = self.relu(summed)
    summed_relu_sigm = torch.sigmoid(summed_relu)

    to_be_multiplied = self.upsample(summed_relu_sigm)
    x_gated = to_be_multiplied * x
    g_up = self.upsample(g)

    out = torch.cat([g_up, x_gated], 1)
    return out