code: def test_get_mask_optimization():
      def model():
          x = pyro.sample("x", dist.Normal(0, 1))
          pyro.sample("y", dist.Normal(x, 1), obs=torch.tensor(0.0))
          called.add("model-always")
          if poutine.get_mask() is not False:
              called.add("model-sometimes")
              pyro.factor("f", x + 1)
  
      def guide():
          x = pyro.sample("x", dist.Normal(0, 1))
          called.add("guide-always")
          if poutine.get_mask() is not False:
              called.add("guide-sometimes")
              pyro.factor("g", 2 - x)
  
      called = set()
      trace = poutine.trace(guide).get_trace()
      poutine.replay(model, trace)()
      assert "model-always" in called
      assert "guide-always" in called
      assert "model-sometimes" in called
      assert "guide-sometimes" in called
  
      called = set()
      with poutine.mask(mask=False):
          trace = poutine.trace(guide).get_trace()
          poutine.replay(model, trace)()
      assert "model-always" in called
      assert "guide-always" in called
      assert "model-sometimes" not in called
      assert "guide-sometimes" not in called
  
      called = set()
      Predictive(model, guide=guide, num_samples=2, parallel=True)()
      assert "model-always" in called
      assert "guide-always" in called
      assert "model-sometimes" not in called
      assert "guide-sometimes" not in called
  
file_path: pyro/tests/infer/test_predictive.py
imports: import pytest
  import torch
  import pyro
  import pyro.distributions
  import pyro.optim
  import pyro.poutine
  from pyro.infer import SVI, Predictive, Trace_ELBO
  from pyro.infer.autoguide import AutoDelta, AutoDiagonalNormal
  from tests.common import assert_close
label_desc: Use image node_id 10 for calling a global function with example usage: test_get_mask_optimization() without return types