def __init__(self, Z, **kwargs):
        # Convert parent to proper type. Z must be a node.
        if not isinstance(Z._moments, CategoricalMoments):
            raise ValueError("Input node must be categorical")
        K = Z.dims[0][-1]
        if K != 2:
            raise Moments.NoConverterError("Only 2-class categorical can be converted to "
                                           "Bernoulli")
        dims = ( (), )
        self._moments = BernoulliMoments()
        self._parent_moments = (CategoricalMoments(2),)
        super().__init__(Z, dims=dims, **kwargs)
Create a categorical MC moments to categorical moments conversion node.
dataset/ETHPy150Open bayespy/bayespy/bayespy/inference/vmp/nodes/bernoulli.py/CategoricalToBernoulli.__init__