code: def assert_immutable(fn):
      """
      Decorator to check that function args are not mutated.
      """
  
      def checked_fn(*args):
          copies = tuple(deep_copy(arg) for arg in args)
          result = fn(*args)
          for pos, (arg, copy) in enumerate(zip(args, copies)):
              if not deep_equal(arg, copy):
                  raise AssertionError(
                      "{} mutated arg {} of type {}.\nOld:\n{}\nNew:\n{}".format(
                          fn.__name__,
                          pos,
                          type(arg).__name__,
                          copy,
                          arg,
                      )
                  )
          return result
  
      return checked_fn
  
imports: import itertools
  import numbers
  from collections import OrderedDict
  import opt_einsum
  import pytest
  import torch
  import pyro.ops.jit
  from pyro.distributions.util import logsumexp
  from pyro.ops.contract import _partition_terms, contract_tensor_tree, contract_to_tensor, einsum, naive_ubersum, ubersum
  from pyro.ops.einsum.adjoint import require_backward
  from pyro.ops.rings import LogRing
  from pyro.poutine.indep_messenger import CondIndepStackFrame
  from pyro.util import optional
  from tests.common import assert_equal
label_desc: Use image node_id 3 for calling a global function with example usage: assert_immutable(fn) and returns: checked_fn, result