Does that mean, simply rewriting it as:
def nccuc(input_A, input_B, n_filters):
    for i, F in enumerate(n_filters):
        if i < 1:
            x0 = input_A
            x1 = nn.Conv2d(in_channels=x0.shape[1], out_channels=F, kernel_size=(3, 3), stride=(1, 1), padding=1)(x0)
            x1 = nn.BatchNorm2d(x1.shape[1])(x1)
            x1 = nn.ReLU()(x1)

        elif i == 1:
            up_conv = nn.ConvTranspose2d(in_channels=x1.shape[1], out_channels=F, kernel_size=4, stride=2, padding=1)(x1)
            up_conv = nn.ReLU()(up_conv)
            return torch.cat((up_conv, input_B), dim=1)

        else:
            return x1

would not work, since the parameters to keep track off are not declared?