<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def observed(obj=None, **kwds):
 """ Decorator function to instantiate data objects. If given a Stochastic, sets a the observed flag to True. Can be used as @observed or as @stochastic(observed=True) :SeeAlso: stochastic, Stochastic, dtrm, Deterministic, potential, Potential, Model, distributions """


    if obj is not None:
        if isinstance(obj, Stochastic):
            obj._observed = True
            return obj
        else:
            p = stochastic(__func__=obj, observed=True, **kwds)
            return p

    kwds['observed'] = True

    def instantiate_observed(func):
        return stochastic(func, **kwds)

    return instantiate_observed