code: def finite_space_model():
      def model(design):
          batch_shape = design.shape
          with ExitStack() as stack:
              for plate in iter_plates_to_shape(batch_shape):
                  stack.enter_context(plate)
              theta = pyro.sample(
                  "theta", dist.Bernoulli(0.4).expand(batch_shape)
              )
              y = pyro.sample(
                  "y", dist.Bernoulli((design + theta) / 2.0)
              )
              return y
  
      return model
  
imports: from contextlib import ExitStack
  import pytest
  import torch
  import pyro
  import pyro.distributions
  import pyro.optim
  from pyro.contrib.oed.eig import donsker_varadhan_eig, lfire_eig, marginal_eig, marginal_likelihood_eig, nmc_eig, posterior_eig, vnmc_eig
  from pyro.contrib.util import iter_plates_to_shape
  from tests.common import assert_equal
label_desc: Use image node_id 1 for calling a global function with example usage: finite_space_model() and returns: model, y