code: def test_scale_and_mask():
      def f(tensor, scale, mask):
          return scale_and_mask(tensor, scale=scale, mask=mask)
  
      x = torch.tensor([-float("inf"), -1.0, 0.0, 1.0, float("inf")])
      y = x / x.unsqueeze(-1)
      mask = y == y
      scale = torch.ones(y.shape)
      jit_f = torch.jit.trace(f, (y, scale, mask))
      assert_equal(jit_f(y, scale, mask), f(y, scale, mask))
  
      mask = torch.tensor([True])
      y = torch.tensor([1.5, 2.5, 3.5, 4.5, 5.5, 6.5])
      scale = torch.ones(y.shape)
      assert_equal(jit_f(y, scale, mask), f(y, scale, mask))
  
imports: import logging
  import warnings
  import pytest
  import torch
  from torch.autograd import grad
  from torch.distributions import constraints, kl_divergence
  import pyro
  import pyro.distributions
  import pyro.ops.jit
  import pyro.poutine
  from pyro.distributions.util import scale_and_mask
  from pyro.infer import SVI, JitTrace_ELBO, JitTraceEnum_ELBO, JitTraceGraph_ELBO, JitTraceMeanField_ELBO, Trace_ELBO, TraceEnum_ELBO, TraceGraph_ELBO, TraceMeanField_ELBO, TraceTMC_ELBO, infer_discrete
  from pyro.optim import Adam
  from pyro.poutine.indep_messenger import CondIndepStackFrame
  from pyro.util import ignore_jit_warnings
  from tests.common import assert_close, assert_equal
label_desc: Use image node_id 7 for calling a global function with example usage: test_scale_and_mask() and returns: scale_and_mask