code: def _test_capture_categorical_sample_outputs():
      """Use monkey-patching to capture the output of an Normal sample."""
      data_container = []
      true_categorical_sample = categorical.Categorical.sample
  
      def _capturing_categorical_sample(
          self, sample_shape=(), seed=None, name="sample", **kwargs
      ):
          samples = true_categorical_sample(
              self, sample_shape, seed, name, **kwargs
          )
          data_container.append(samples)
          return samples
  
      categorical.Categorical.sample = _capturing_categorical_sample
      yield data_container
      categorical.Categorical.sample = true_categorical_sample
  
imports: import contextlib
  import warnings
  import numpy
  from scipy import stats
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import dirichlet
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import gamma
  from tensorflow_probability.python.distributions import half_normal
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import mixture
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import mvn_tril
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import hypothesis_testlib
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 5 for calling a global function with example usage: _test_capture_categorical_sample_outputs() and returns: samples