class_docstr: Related to minibatch training
class_docstr_tok: ["Related","to","minibatch","training"]
code: def test_gradient_with_scaling(self):
      with pm.Model() as model1:
          genvar = pm.generator(gen1())
          m = pm.Normal("m")
          pm.Normal("n", observed=genvar, total_size=1000)
          grad1 = model1.compile_fn(
              model1.dlogp(vars=m), point_fn=False
          )
      with pm.Model() as model2:
          m = pm.Normal("m")
          shavar = pytensor.shared(np.ones((1000, 100)))
          pm.Normal("n", observed=shavar)
          grad2 = model2.compile_fn(
              model2.dlogp(vars=m), point_fn=False
          )
  
      for i in range(10):
          shavar.set_value(np.ones((100, 100)) * i)
          g1 = grad1(1)
          g2 = grad2(1)
          np.testing.assert_almost_equal(g1, g2)
  
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 3 for calling the TestMinibatchRandomVariable obj's underlying member method code with example usage: obj.test_gradient_with_scaling() without return types