How to evaluate Poisson log-likelihood from arviz.InferenceData after successful PyMC fitting?

Hmm… according to Model comparison — PyMC 5.3.1 documentation that function can only be called within a “with model” context. Whereas in my case, since my model takes a long time to run and since I have many such models to run, I saved it as a file via trace.to_netcdf('filename.nc') . When I read it back in using arviz via trace = az.from_netcdf('filename.nc') and then try pm.compute_log_likelihood(trace) I get this error:

File /opt/anaconda3/envs/pymc/lib/python3.11/site-packages/pymc/stats/log_likelihood.py:63, in compute_log_likelihood(idata, var_names, extend_inferencedata, model, sample_dims, progressbar)
     40 """Compute elemwise log_likelihood of model given InferenceData with posterior group
     41 
     42 Parameters
   (...)
     58 
     59 """
     61 posterior = idata["posterior"]
---> 63 model = modelcontext(model)
     65 if var_names is None:
     66     observed_vars = model.observed_RVs

File /opt/anaconda3/envs/pymc/lib/python3.11/site-packages/pymc/model.py:279, in modelcontext(model)
    274     model = Model.get_context(error_if_none=False)
    276     if model is None:
    277         # TODO: This should be a ValueError, but that breaks
    278         # ArviZ (and others?), so might need a deprecation.
--> 279         raise TypeError("No model on context stack.")
    280 return model

TypeError: No model on context stack.

Can that function not be used on pre-existing saved files that are re-read in as arviz.InferenceData?