code: def test_dctadam_param_subsample():
      outer_size = 7
      middle_size = 2
      inner_size = 11
      outer_subsize = 3
      inner_subsize = 4
      event_size = 5
  
      def model():
          with pyro.plate(
              "outer", outer_size, subsample_size=outer_subsize, dim=-3
          ):
              with pyro.plate(
                  "inner",
                  inner_size,
                  subsample_size=inner_subsize,
                  dim=-1,
              ):
                  pyro.param(
                      "loc",
                      torch.randn(
                          outer_size,
                          middle_size,
                          inner_size,
                          event_size,
                      ),
                      event_dim=1,
                  )
  
      optimizer = optim.DCTAdam({"lr": 1.0, "subsample_aware": True})
      model()
      param = pyro.param("loc").unconstrained()
      param.sum().backward()
      pre_optimized_value = param.detach().clone()
      optimizer({param})
      expected_num_changes = (
          outer_subsize * middle_size * inner_subsize * event_size
      )
      actual_num_changes = (
          ((param - pre_optimized_value) != 0).sum().item()
      )
      assert actual_num_changes == expected_num_changes
  
      for i in range(1000):
          pyro.infer.util.zero_grads({param})
          model()  # generate new subsample indices
          param.pow(2).sum().backward()
          optimizer({param})
  
      assert_equal(param, param.new_zeros(param.shape), prec=1e-2)
  
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 7 for calling a global function with example usage: test_dctadam_param_subsample() without return types