code: def do_test_per_param_optim(self, fixed_param, free_param):
      pyro.clear_param_store()
  
      def model():
          prior_dist = Normal(self.loc0, torch.pow(self.lam0, -0.5))
          loc_latent = pyro.sample("loc_latent", prior_dist)
          x_dist = Normal(loc_latent, torch.pow(self.lam, -0.5))
          pyro.sample("obs", x_dist, obs=self.data)
          return loc_latent
  
      def guide():
          loc_q = pyro.param(
              "loc_q", torch.zeros(1, requires_grad=True)
          )
          log_sig_q = pyro.param(
              "log_sig_q", torch.zeros(1, requires_grad=True)
          )
          sig_q = torch.exp(log_sig_q)
          pyro.sample("loc_latent", Normal(loc_q, sig_q))
  
      def optim_params(param_name):
          if param_name == fixed_param:
              return {"lr": 0.00}
          elif param_name == free_param:
              return {"lr": 0.01}
  
      def get_steps(adam):
          state = adam.get_state()["loc_q"]["state"]
          return int(list(state.values())[0]["step"])
  
      adam = optim.Adam(optim_params)
      adam2 = optim.Adam(optim_params)
      svi = SVI(model, guide, adam, loss=TraceGraph_ELBO())
      svi2 = SVI(model, guide, adam2, loss=TraceGraph_ELBO())
  
      svi.step()
      adam_initial_step_count = get_steps(adam)
      with TemporaryDirectory() as tempdir:
          filename = os.path.join(tempdir, "optimizer_state.pt")
          adam.save(filename)
          svi.step()
          adam_final_step_count = get_steps(adam)
          adam2.load(filename)
      svi2.step()
      adam2_step_count_after_load_and_step = get_steps(adam2)
  
      assert adam_initial_step_count == 1
      assert adam_final_step_count == 2
      assert adam2_step_count_after_load_and_step == 2
  
      free_param_unchanged = torch.equal(
          pyro.param(free_param).data, torch.zeros(1)
      )
      fixed_param_unchanged = torch.equal(
          pyro.param(fixed_param).data, torch.zeros(1)
      )
      assert fixed_param_unchanged and not free_param_unchanged
  
imports: import os
  from tempfile import TemporaryDirectory
  from unittest import TestCase
  import pytest
  import torch
  from torch.distributions import constraints
  import pyro
  import pyro.distributions
  import pyro.optim
  from pyro import poutine
  from pyro.distributions import Normal, Uniform
  from pyro.infer import SVI, Trace_ELBO, TraceGraph_ELBO
  from pyro.nn.module import PyroModule, PyroParam, to_pyro_module_
  from pyro.optim.optim import is_scheduler
  from tests.common import assert_equal
label_desc: Use image node_id 3 for calling the OptimTests obj's underlying member method code with example usage: obj.do_test_per_param_optim(fixed_param, free_param) and returns: loc_latent, int, dict, dict