def __call__(self, x):
    if self.dr:
        with chainer.using_config('train', True):
            x = F.dropout(x, self.dr)
    if self.gap:
        x = F.sum(x, axis=(2, 3))
    N = x.shape[0]
    feature = F.reshape(F.leaky_relu(x), (N, (- 1)))
    m = F.reshape(self.md(feature), (N, (self.B * self.C), 1))
    m0 = F.broadcast_to(m, (N, (self.B * self.C), N))
    m1 = F.transpose(m0, (2, 1, 0))
    d = F.absolute(F.reshape((m0 - m1), (N, self.B, self.C, N)))
    d = (F.sum(F.exp((- F.sum(d, axis=2))), axis=2) - 1)
    h = F.concat([feature, d])
    h = self.l(h)
    return h
def __call__(self, x):
    if self.dr:
        with chainer.using_config('train', True):
            x = F.dropout(x, self.dr)
    if self.gap:
        x = F.sum(x, axis=(2, 3))
    N = x.shape[0]
    feature = F.reshape(F.leaky_relu(x), (N, (- 1)))
    m = F.reshape(self.md(feature), (N, (self.B * self.C), 1))
    m0 = F.broadcast_to(m, (N, (self.B * self.C), N))
    m1 = F.transpose(m0, (2, 1, 0))
    d = F.absolute(F.reshape((m0 - m1), (N, self.B, self.C, N)))
    d = (F.sum(F.exp((- F.sum(d, axis=2))), axis=2) - 1)
    h = F.concat([feature, d])
    h = self.l(h)
    return h