def __init__(self, encoder_channels, decoder_channels, n_blocks=5, use_batchnorm=True, attention_type=None, center=False):
    super().__init__()
    if (n_blocks != len(decoder_channels)):
        raise ValueError('Model depth is {}, but you provide `decoder_channels` for {} blocks.'.format(n_blocks, len(decoder_channels)))
    encoder_channels = encoder_channels[1:]
    encoder_channels = encoder_channels[::(- 1)]
    head_channels = encoder_channels[0]
    in_channels = ([head_channels] + list(decoder_channels[:(- 1)]))
    skip_channels = (list(encoder_channels[1:]) + [0])
    out_channels = decoder_channels
    if center:
        self.center = CenterBlock(head_channels, head_channels, use_batchnorm=use_batchnorm)
    else:
        self.center = nn.Identity()
    kwargs = dict(use_batchnorm=use_batchnorm, attention_type=attention_type)
    blocks = [DecoderBlock(in_ch, skip_ch, out_ch, **kwargs) for (in_ch, skip_ch, out_ch) in zip(in_channels, skip_channels, out_channels)]
    self.blocks = nn.ModuleList(blocks)
def __init__(self, encoder_channels, decoder_channels, n_blocks=5, use_batchnorm=True, attention_type=None, center=False):
    super().__init__()
    if (n_blocks != len(decoder_channels)):
        raise ValueError('Model depth is {}, but you provide `decoder_channels` for {} blocks.'.format(n_blocks, len(decoder_channels)))
    encoder_channels = encoder_channels[1:]
    encoder_channels = encoder_channels[::(- 1)]
    head_channels = encoder_channels[0]
    in_channels = ([head_channels] + list(decoder_channels[:(- 1)]))
    skip_channels = (list(encoder_channels[1:]) + [0])
    out_channels = decoder_channels
    if center:
        self.center = CenterBlock(head_channels, head_channels, use_batchnorm=use_batchnorm)
    else:
        self.center = nn.Identity()
    kwargs = dict(use_batchnorm=use_batchnorm, attention_type=attention_type)
    blocks = [DecoderBlock(in_ch, skip_ch, out_ch, **kwargs) for (in_ch, skip_ch, out_ch) in zip(in_channels, skip_channels, out_channels)]
    self.blocks = nn.ModuleList(blocks)