code: def _remove_features_missing_common_stats(
      stats: statistics_pb2.DatasetFeatureStatistics,
  ) -> statistics_pb2.DatasetFeatureStatistics:
      """Remove FeatureNameStatistics for feature paths missing common stats.
  
      Args:
        stats: The stats from which to remove features
  
      Returns:
        A version of the input stats with the feature paths removed.
      """
      valid_features = []
      for feature in stats.features:
          if (
              feature.HasField("num_stats")
              or feature.HasField("string_stats")
              or feature.HasField("bytes_stats")
              or feature.HasField("struct_stats")
          ):
              valid_features.append(feature)
      del stats.features[:]
      stats.features.extend(valid_features)
      return stats
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import itertools
  import logging
  from typing import Callable, Iterable, List, Optional, Text, Tuple, Set
  import apache_beam
  import pyarrow
  import tensorflow
  from tensorflow_data_validation import constants
  from tensorflow_data_validation import types
  from tensorflow_data_validation.anomalies.proto import custom_validation_config_pb2
  from tensorflow_data_validation.anomalies.proto import validation_config_pb2
  from tensorflow_data_validation.anomalies.proto import validation_metadata_pb2
  from tensorflow_data_validation.api import validation_options
  from tensorflow_data_validation.pywrap.tensorflow_data_validation_extension import validation
  from tensorflow_data_validation.skew import feature_skew_detector
  from tensorflow_data_validation.skew.protos import feature_skew_results_pb2
  from tensorflow_data_validation.statistics import stats_impl
  from tensorflow_data_validation.statistics import stats_options
  from tensorflow_data_validation.utils import anomalies_util
  from tensorflow_data_validation.utils import slicing_util
  from tensorflow_data_validation.utils import stats_util
  from tensorflow_metadata.proto.v0 import anomalies_pb2
  from tensorflow_metadata.proto.v0 import schema_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 9 for calling a global function with example usage: _remove_features_missing_common_stats(stats) and returns: stats