code: def generate_data(num_frames, num_sensors):
      """
      Generate data from a damped NCV dynamics model
      """
      dt = TIME_STEP
      bias_scale = 4.0
      obs_noise = 1.0
      trans_noise = 0.3
  
      # define dynamics
      z = torch.cat(
          [10.0 * torch.randn(2), torch.rand(2)]
      )  # position  # velocity
      damp = 0.1  # damp the velocities
      f = torch.tensor(
          [
              [1, 0, 0, 0],
              [0, 1, 0, 0],
              [dt * math.exp(-damp * dt), 0, math.exp(-damp * dt), 0],
              [0, dt * math.exp(-damp * dt), 0, math.exp(-damp * dt)],
          ]
      )
      trans_dist = dist.MultivariateNormal(
          torch.zeros(4),
          scale_tril=trans_noise
          * torch.linalg.cholesky(NCV_PROCESS_NOISE),
      )
  
      # define biased sensors
      sensor_bias = bias_scale * torch.randn(2 * num_sensors)
      h = (
          torch.eye(4, 2)
          .unsqueeze(-1)
          .expand(-1, -1, num_sensors)
          .reshape(4, -1)
      )
      obs_dist = dist.MultivariateNormal(
          sensor_bias, scale_tril=obs_noise * torch.eye(2 * num_sensors)
      )
  
      states = []
      observations = []
      for t in range(num_frames):
          z = z @ f + trans_dist.sample()
          states.append(z)
  
          x = z @ h + obs_dist.sample()
          observations.append(x)
  
      states = torch.stack(states)
      observations = torch.stack(observations)
      assert observations.shape == (num_frames, num_sensors * 2)
      return observations, states, sensor_bias
  
imports: import argparse
  import itertools
  import math
  import os
  import pyro.distributions
  import torch
  import torch.nn
  from torch.optim import Adam
  import funsor
  import funsor.ops
  import funsor.torch.distributions
  from funsor.domains import Reals
  from funsor.pyro.convert import dist_to_funsor, funsor_to_mvn
  from funsor.tensor import Tensor, Variable
label_desc: Use image node_id 1 for calling a global function with example usage: generate_data(num_frames, num_sensors) and returns: observations,  states,  sensor_bias