code: def _resample_scale(
      prior, observed_residuals, is_missing=None, seed=None
  ):
      """Samples a scale parameter from its conditional posterior.
  
      We assume the conjugate InverseGamma->Normal model:
  
      ```
      scale ~ Sqrt(InverseGamma(prior.concentration, prior.scale))
      for i in [1, ..., num_observations]:
        x[i] ~ Normal(loc, scale)
      ```
  
      in which `loc` is known, and return a sample from `p(scale | x)`.
  
      Args:
        prior: Prior distribution as a `tfd.InverseGamma` instance.
        observed_residuals: Float `Tensor` of shape `[..., num_observations]`,
          specifying the centered observations `(x - loc)`.
        is_missing: Optional `bool` `Tensor` of shape `[..., num_observations]`. A
          `True` value indicates that the corresponding observation is missing.
        seed: Optional `Python` `int` seed controlling the sampled value.
  
      Returns:
        sampled_scale: A `Tensor` sample from the posterior `p(scale | x)`.
      """
      posterior = sample_parameters.normal_scale_posterior_inverse_gamma_conjugate(
          prior, observed_residuals, is_missing
      )
      return sample_parameters.sample_with_optional_upper_bound(
          posterior, seed=seed
      )
  
imports: import collections
  import itertools
  import numpy
  import six
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import identity
  from tensorflow_probability.python.bijectors import invert
  from tensorflow_probability.python.bijectors import square
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import gamma
  from tensorflow_probability.python.distributions import inverse_gamma
  from tensorflow_probability.python.distributions import mixture_same_family
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import mvn_linear_operator
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import normal_conjugate_posteriors
  from tensorflow_probability.python.distributions import transformed_distribution
  from tensorflow_probability.python.experimental.distributions import mvn_precision_factor_linop
  from tensorflow_probability.python.experimental.sts_gibbs import dynamic_spike_and_slab
  from tensorflow_probability.python.experimental.sts_gibbs import sample_parameters
  from tensorflow_probability.python.experimental.sts_gibbs import spike_and_slab
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.sts.components import local_level
  from tensorflow_probability.python.sts.components import local_linear_trend
  from tensorflow_probability.python.sts.components import regression
  from tensorflow_probability.python.sts.components import seasonal
  from tensorflow_probability.python.sts.components import sum
  from tensorflow_probability.python.sts.internal import util
label_desc: Use image node_id 11 for calling a global function with example usage: _resample_scale(prior, observed_residuals, is_missing, seed) and returns: sample_parameters