def METHOD_NAME(self, weight):
    if self._per_channel:
        weight_tmp = weight.detach().reshape((weight.shape[0], -1))
        mean = paddle.mean(weight_tmp, axis=self._collect_axis)
        std = paddle.std(weight_tmp, axis=self._collect_axis)
        s = paddle.max(
            paddle.stack(
                [paddle.abs(mean - 3 * std),
                 paddle.abs(mean + 3 * std)]),
            axis=0, )
        self._scale.set_value(s * 0.9 + 0.1 * s / self.div)
    else:
        mean = paddle.mean(weight.detach())
        std = paddle.std(weight.detach())
        self._scale.set_value(self._scale * 0.9 + 0.1 * max(
            [paddle.abs(mean - 3 * std),
             paddle.abs(mean + 3 * std)]) / self.div)
    self._init_state += 1