code: def _get_components(
      sparse_features: Iterable[
          Tuple[types.FeaturePath, schema_pb2.SparseFeature]
      ]
  ) -> Dict[types.FeaturePath, _SparseFeatureComponents]:
      """Returns the index and value feature paths that comprise sparse features."""
      # A dict mapping sparse feature paths to their component index and value
      # feature paths.
      sparse_feature_components = dict()
      # The index and value features for a given sparse feature have the same parent
      # path as the sparse feature.
      for path, feature in sparse_features:
          parent_path = path.parent()
          value_feature = parent_path.child(feature.value_feature.name)
          index_features = set()
          for index_feature in feature.index_feature:
              index_features.add(parent_path.child(index_feature.name))
          sparse_feature_components[path] = _SparseFeatureComponents(
              value_feature, index_features
          )
      return sparse_feature_components
  
file_path: data-validation/tensorflow_data_validation/statistics/generators/sparse_feature_stats_generator.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Dict, Iterable, List, Text, Tuple, Union
  from tensorflow_data_validation import types
  from tensorflow_data_validation.statistics.generators import stats_generator
  from tensorflow_data_validation.statistics.generators.constituents import count_missing_generator
  from tensorflow_data_validation.statistics.generators.constituents import length_diff_generator
  from tensorflow_metadata.proto.v0 import schema_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
  from tfx_bsl.types import tfx_namedtuple
label_desc: Use image node_id 2 for calling a global function with example usage: _get_components(sparse_features) and returns: sparse_feature_components