code: def image_to_window(z_where, window_size, image_size, images):
      n = images.size(0)
      assert (
          images.size(1) == images.size(2) == image_size
      ), "Size mismatch."
      theta_inv = expand_z_where(z_where_inv(z_where))
      grid = F.affine_grid(
          theta_inv, torch.Size((n, 1, window_size, window_size))
      )
      out = F.grid_sample(
          images.view(n, 1, image_size, image_size), grid
      )
      return out.view(n, -1)
  
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 5 for calling a global function with example usage: image_to_window(z_where, window_size, image_size, images) and returns: out