code: def model_8(weeks_data, days_data, history, vectorized):
      x_dim, y_dim, w_dim, z_dim = 3, 2, 2, 3
      x_init = pyro.param(
          "x_init",
          lambda: torch.rand(x_dim),
          constraint=constraints.simplex,
      )
      x_trans = pyro.param(
          "x_trans",
          lambda: torch.rand((x_dim, x_dim)),
          constraint=constraints.simplex,
      )
      y_probs = pyro.param(
          "y_probs",
          lambda: torch.rand(x_dim, y_dim),
          constraint=constraints.simplex,
      )
      w_init = pyro.param(
          "w_init",
          lambda: torch.rand(w_dim),
          constraint=constraints.simplex,
      )
      w_trans = pyro.param(
          "w_trans",
          lambda: torch.rand((w_dim, w_dim)),
          constraint=constraints.simplex,
      )
      z_probs = pyro.param(
          "z_probs",
          lambda: torch.rand(w_dim, z_dim),
          constraint=constraints.simplex,
      )
  
      x_prev = None
      weeks_loop = (
          pyro.vectorized_markov(
              name="weeks",
              size=len(weeks_data),
              dim=-1,
              history=history,
          )
          if vectorized
          else pyro.markov(range(len(weeks_data)), history=history)
      )
      for i in weeks_loop:
          if isinstance(i, int) and i == 0:
              x_probs = x_init
          else:
              x_probs = Vindex(x_trans)[x_prev]
  
          x_curr = pyro.sample(
              "x_{}".format(i), dist.Categorical(x_probs)
          )
          pyro.sample(
              "y_{}".format(i),
              dist.Categorical(Vindex(y_probs)[x_curr]),
              obs=weeks_data[i],
          )
          x_prev = x_curr
  
      w_prev = None
      days_loop = (
          pyro.vectorized_markov(
              name="days", size=len(days_data), dim=-1, history=history
          )
          if vectorized
          else pyro.markov(range(len(days_data)), history=history)
      )
      for j in days_loop:
          if isinstance(j, int) and j == 0:
              w_probs = w_init
          else:
              w_probs = Vindex(w_trans)[w_prev]
  
          w_curr = pyro.sample(
              "w_{}".format(j), dist.Categorical(w_probs)
          )
          pyro.sample(
              "z_{}".format(j),
              dist.Categorical(Vindex(z_probs)[w_curr]),
              obs=days_data[j],
          )
          w_prev = w_curr
  
imports: import pytest
  import torch
  from pyroapi import pyro_backend
  from torch.distributions import constraints
  from pyro.ops.indexing import Vindex
label_desc: Use image node_id 11 for calling a global function with example usage: model_8(weeks_data, days_data, history, vectorized) without return types