class_docstr: Generates statistics for sparse features.
class_docstr_tok: ["Generates","statistics","for","sparse","features","."]
docstr: Initializes a sparse feature statistics generator.
  
  Args:
    schema: A required schema for the dataset.
    name: An optional unique name associated with the statistics generator.
docstr_tok: ["Initializes","a","sparse","feature","statistics","generator",".","Args",":","schema",":","A","required","schema","for","the","dataset",".","name",":","An","optional","unique","name","associated","with","the","statistics","generator","."]
code: def __init__(
      self,
      schema: schema_pb2.Schema,
      name: Text = "SparseFeatureStatsGenerator",
  ) -> None:
      """Initializes a sparse feature statistics generator.
  
      Args:
        schema: A required schema for the dataset.
        name: An optional unique name associated with the statistics generator.
      """
      self._sparse_feature_components = _get_components(
          _get_all_sparse_features(schema)
      )
  
      # Create length diff generators for each index / value pair and count
      # missing generator for all paths.
      constituents = []
      for _, (
          value,
          indices,
      ) in self._sparse_feature_components.items():
          required_paths = [value] + list(indices)
          constituents.append(
              count_missing_generator.CountMissingGenerator(
                  value, required_paths
              )
          )
          for index in indices:
              constituents.append(
                  length_diff_generator.LengthDiffGenerator(
                      index, value, required_paths
                  )
              )
              constituents.append(
                  count_missing_generator.CountMissingGenerator(
                      index, required_paths
                  )
              )
  
      super(SparseFeatureStatsGenerator, self).__init__(
          name, constituents, schema
      )
  
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 1 to create a new SparseFeatureStatsGenerator object from inherited base classes: stats_generator with example: obj = SparseFeatureStatsGenerator(schema, name)