code: def prior_step(
      self, t, n, prev, z_pres_prior_p=default_z_pres_prior_p
  ):
      # Sample presence indicators.
      z_pres = pyro.sample(
          "z_pres_{}".format(t),
          dist.Bernoulli(z_pres_prior_p(t) * prev.z_pres).to_event(1),
      )
  
      # If zero is sampled for a data point, then no more objects
      # will be added to its output image. We can't
      # straight-forwardly avoid generating further objects, so
      # instead we zero out the log_prob_sum of future choices.
      sample_mask = z_pres if self.use_masking else torch.tensor(1.0)
  
      # Sample attention window position.
      z_where = pyro.sample(
          "z_where_{}".format(t),
          dist.Normal(
              self.z_where_loc_prior.expand(n, self.z_where_size),
              self.z_where_scale_prior.expand(n, self.z_where_size),
          )
          .mask(sample_mask)
          .to_event(1),
      )
  
      # Sample latent code for contents of the attention window.
      z_what = pyro.sample(
          "z_what_{}".format(t),
          dist.Normal(
              torch.zeros(n, self.z_what_size, **self.options),
              torch.ones(n, self.z_what_size, **self.options),
          )
          .mask(sample_mask)
          .to_event(1),
      )
  
      # Map latent code to pixel space.
      y_att = self.decode(z_what)
  
      # Position/scale attention window within larger image.
      y = window_to_image(z_where, self.window_size, self.x_size, y_att)
  
      # Combine the image generated at this step with the image so far.
      # (Note that there's no notion of occlusion here. Overlapping
      # objects can create pixel intensities > 1.)
      x = prev.x + (y * z_pres.view(-1, 1, 1))
  
      return ModelState(x=x, z_pres=z_pres, z_where=z_where)
  
imports: from collections import namedtuple
  import torch
  import torch.nn
  import torch.nn.functional
  from modules import MLP, Decoder, Encoder, Identity, Predict
  import pyro
  import pyro.distributions
label_desc: Use image node_id 3 for calling the AIR obj's underlying member method code with example usage: obj.prior_step(t, n, prev, z_pres_prior_p) and returns: ModelState