def __init__(self, w, comp_dists, *args, **kwargs):
    shape = kwargs.pop('shape', ())
    self.w = w = tt.as_tensor_variable(w)
    self.comp_dists = comp_dists
    defaults = kwargs.pop('defaults', [])
    if all_discrete(comp_dists):
        dtype = kwargs.pop('dtype', 'int64')
    else:
        dtype = kwargs.pop('dtype', 'float64')
        try:
            self.mean = (w * self._comp_means()).sum(axis=(- 1))
            if ('mean' not in defaults):
                defaults.append('mean')
        except AttributeError:
            pass
    try:
        comp_modes = self._comp_modes()
        comp_mode_logps = self.logp(comp_modes)
        self.mode = comp_modes[tt.argmax((w * comp_mode_logps), axis=(- 1))]
        if ('mode' not in defaults):
            defaults.append('mode')
    except AttributeError:
        pass
    super(Mixture, self).__init__(shape, dtype, *args, defaults=defaults, **kwargs)
def __init__(self, w, comp_dists, *args, **kwargs):
    shape = kwargs.pop('shape', ())
    self.w = w = tt.as_tensor_variable(w)
    self.comp_dists = comp_dists
    defaults = kwargs.pop('defaults', [])
    if all_discrete(comp_dists):
        dtype = kwargs.pop('dtype', 'int64')
    else:
        dtype = kwargs.pop('dtype', 'float64')
        try:
            self.mean = (w * self._comp_means()).sum(axis=(- 1))
            if ('mean' not in defaults):
                defaults.append('mean')
        except AttributeError:
            pass
    try:
        comp_modes = self._comp_modes()
        comp_mode_logps = self.logp(comp_modes)
        self.mode = comp_modes[tt.argmax((w * comp_mode_logps), axis=(- 1))]
        if ('mode' not in defaults):
            defaults.append('mode')
    except AttributeError:
        pass
    super(Mixture, self).__init__(shape, dtype, *args, defaults=defaults, **kwargs)