code: def _get_components_from_model(model):
      """Returns the split-apart components from an STS model.
  
      Args:
        model: A `tf.sts.StructuralTimeSeries` to split apart.
  
      Returns:
        A tuple of (index and level component, index and regression component,
        indices and seasonal components) or an exception.
        The regression component may be None (along with its index - (None, None)).
  
        Each 'index and component' is a tuple of (index, component), where index
        is the position in the model.
      """
      if not hasattr(model, "supports_gibbs_sampling"):
          raise ValueError(
              "This STS model does not support Gibbs sampling. Models "
              "for Gibbs sampling must be created using the "
              "method `build_model_for_gibbs_fitting`."
          )
  
      level_components = []
      regression_components = []
      seasonal_components = []
  
      for index, component in enumerate(model.components):
          if isinstance(
              component, local_level.LocalLevel
          ) or isinstance(
              component, local_linear_trend.LocalLinearTrend
          ):
              level_components.append((index, component))
          elif isinstance(
              component, regression.LinearRegression
          ) or isinstance(
              component, SpikeAndSlabSparseLinearRegression
          ):
              regression_components.append((index, component))
          elif isinstance(component, seasonal.Seasonal):
              seasonal_components.append((index, component))
          else:
              raise NotImplementedError(
                  "Found unsupported model component for Gibbs Sampling: {}".format(
                      component
                  )
              )
  
      if len(level_components) != 1:
          raise ValueError(
              "Expected exactly one level component, found {} components.".format(
                  len(level_components)
              )
          )
      level_component = level_components[0]
  
      regression_component = (None, None)
      if len(regression_components) > 1:
          raise ValueError(
              "Expected at most one regression component, found {} components.".format(
                  len(regression_components)
              )
          )
      elif len(regression_components) == 1:
          regression_component = regression_components[0]
      return level_component, regression_component, seasonal_components
  
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 12 for calling a global function with example usage: _get_components_from_model(model) and returns: level_component,  regression_component,  seasonal_components