class_docstr: Related to minibatch training
class_docstr_tok: ["Related","to","minibatch","training"]
code: def test_density_scaling_with_generator(self):
      # We have different size generators
  
      def true_dens():
          g = gen1()
          for i, point in enumerate(g):
              yield st.norm.logpdf(point).sum() * 10
  
      t = true_dens()
      # We have same size models
      with pm.Model() as model1:
          pm.Normal("n", observed=gen1(), total_size=100)
          p1 = pytensor.function([], model1.logp())
  
      with pm.Model() as model2:
          gen_var = pm.generator(gen2())
          pm.Normal("n", observed=gen_var, total_size=100)
          p2 = pytensor.function([], model2.logp())
  
      for i in range(10):
          _1, _2, _t = p1(), p2(), next(t)
          decimals = select_by_precision(float64=7, float32=1)
          np.testing.assert_almost_equal(
              _1, _t, decimal=decimals
          )  # Value O(-50,000)
          np.testing.assert_almost_equal(_1, _2)
  
file_path: pymc/tests/variational/test_minibatch_rv.py
imports: import numpy
  import pytensor
  import pytest
  from scipy import stats
  import pymc
  from pymc import Normal, draw
  from pymc.data import minibatch_index
  from pymc.testing import select_by_precision
  from pymc.variational.minibatch_rv import create_minibatch_rv
  from tests.test_data import gen1, gen2
label_desc: Use image node_id 2 for calling the TestMinibatchRandomVariable obj's underlying member method code with example usage: obj.test_density_scaling_with_generator() without return types