def make_node(self, rv, val): """Make an `Observed` random variable. Parameters ---------- rv: RandomVariable The distribution from which `val` is assumed to be a sample value. val: Variable The observed value. """ val = as_tensor_variable(val) if rv is not None: if not hasattr(rv, "type") or rv.type.convert_variable(val) is None: raise TypeError( ( "`rv` and `val` do not have compatible types:" f" rv={rv}, val={val}" ) ) else: rv = NoneConst.clone() inputs = [rv, val] return Apply(self, inputs, [val.type()])