code: def test_multivariate_normal_model():
      def model(data):
          loc = pyro.sample(
              "loc",
              dist.Normal(torch.zeros(3), torch.ones(3)).to_event(1),
          )
          scale_tril = torch.eye(3)
          with pyro.plate("data", len(data)):
              pyro.sample(
                  "obs",
                  dist.NanMaskedMultivariateNormal(
                      loc, scale_tril=scale_tril
                  ),
                  obs=data,
              )
  
      data = torch.randn(100, 3)
      ok = torch.rand(100, 3) < 0.5
      assert 100 < ok.long().sum() < 200, "weak test"
      data[~ok] = math.nan
  
      guide = AutoNormal(model)
      svi = SVI(model, guide, Adam({"lr": 1e-4}), Trace_ELBO())
      for step in range(3):
          loss = svi.step(data)
          assert math.isfinite(loss)
  
file_path: pyro/tests/distributions/test_nanmasked.py
imports: import math
  import pytest
  import torch
  import pyro
  import pyro.distributions
  from pyro.infer import SVI, Trace_ELBO
  from pyro.infer.autoguide import AutoNormal
  from pyro.optim import Adam
  from tests.common import assert_close
label_desc: Use image node_id 3 for calling a global function with example usage: test_multivariate_normal_model() without return types