code: def set_approx_sample_thresh(thresh):
      """
      EXPERIMENTAL Context manager / decorator to temporarily set the global
      default value of ``Binomial.approx_sample_thresh``, thereby decreasing the
      computational complexity of sampling from
      :class:`~pyro.distributions.Binomial`,
      :class:`~pyro.distributions.BetaBinomial`,
      :class:`~pyro.distributions.ExtendedBinomial`,
      :class:`~pyro.distributions.ExtendedBetaBinomial`, and distributions
      returned by :func:`infection_dist`.
  
      This is useful for sampling from very large ``total_count``.
  
      This is used internally by
      :class:`~pyro.contrib.epidemiology.compartmental.CompartmentalModel`.
  
      :param thresh: New temporary threshold.
      :type thresh: int or float.
      """
      assert isinstance(thresh, (float, int))
      assert thresh > 0
      old = dist.Binomial.approx_sample_thresh
      try:
          dist.Binomial.approx_sample_thresh = thresh
          yield
      finally:
          dist.Binomial.approx_sample_thresh = old
  
file_path: pyro/pyro/contrib/epidemiology/distributions.py
imports: import math
  from contextlib import contextmanager
  import torch
  from torch.distributions.utils import broadcast_all
  import pyro.distributions
  from pyro.distributions.util import is_validation_enabled
label_desc: Use image node_id 3 for calling a global function with example usage: set_approx_sample_thresh(thresh) without return types