Save variable calculated inside of logp function

Hi,

I would like to reuse a variable - myvariable say - , which I calculate in my custom likelihood, outside of this class to save some computation time. However, I cant access any variables of the logp function from outside the class, but would still like to store myvariable (e.g. in the backend) somehow.

I have tried to include a
pm.Deterministic(‘myvariable’, myvariable) inside the logp function to store it, however, that doesnt work.

I appreciate any further hints on this matter.
Thanks!

Hard to say without seeing the actual implementation you’ve got. I would usually use a class to save state, but the deterministic approach should work. Can you share any more details?