def make_observed_model(model, obs_to_model_args_fn):
    ' Transforms a generative model function into one with fixed observations\n    for likelihood evaluation in the SVI algorithm.\n\n    :param model: Any generative model function using the numpyro `sample`\n        primitive.\n    :param obs_to_model_args_fn: A function mapping from an argument list compatible\n        with SVI (i.e., accepting a batch of observations) to that of `model`. The\n        mapping function can take arbitrary arguments and must return a tuple\n        (args, kwargs, observations), where args and kwargs are passed to `model`\n        as argument and keyword arguments and observations is a dictionary of\n        observations for sample sites in `model` that will be fixed using the\n        `observe` handler.\n    '

    def transformed_model_fn(*args, **kwargs):
        (mapped_args, mapped_kwargs, fixed_obs) = obs_to_model_args_fn(*args, **kwargs)
        return condition(model, data=fixed_obs)(*mapped_args, **mapped_kwargs)
    return transformed_model_fn
Transforms a generative model function into one with fixed observations
for likelihood evaluation in the SVI algorithm.

:param model: Any generative model function using the numpyro `sample`
    primitive.
:param obs_to_model_args_fn: A function mapping from an argument list compatible
    with SVI (i.e., accepting a batch of observations) to that of `model`. The
    mapping function can take arbitrary arguments and must return a tuple
    (args, kwargs, observations), where args and kwargs are passed to `model`
    as argument and keyword arguments and observations is a dictionary of
    observations for sample sites in `model` that will be fixed using the
    `observe` handler.
def make_observed_model(model, obs_to_model_args_fn):
    ' Transforms a generative model function into one with fixed observations\n    for likelihood evaluation in the SVI algorithm.\n\n    :param model: Any generative model function using the numpyro `sample`\n        primitive.\n    :param obs_to_model_args_fn: A function mapping from an argument list compatible\n        with SVI (i.e., accepting a batch of observations) to that of `model`. The\n        mapping function can take arbitrary arguments and must return a tuple\n        (args, kwargs, observations), where args and kwargs are passed to `model`\n        as argument and keyword arguments and observations is a dictionary of\n        observations for sample sites in `model` that will be fixed using the\n        `observe` handler.\n    '

    def transformed_model_fn(*args, **kwargs):
        (mapped_args, mapped_kwargs, fixed_obs) = obs_to_model_args_fn(*args, **kwargs)
        return condition(model, data=fixed_obs)(*mapped_args, **mapped_kwargs)
    return transformed_model_fn