code: def _project_statistics(
      statistics: statistics_pb2.DatasetFeatureStatisticsList,
      allowlist_features: Optional[List[types.FeaturePath]] = None,
      denylist_features: Optional[List[types.FeaturePath]] = None,
  ) -> statistics_pb2.DatasetFeatureStatisticsList:
      """Project statistics proto based on allowlist and denylist features."""
      if allowlist_features is None and denylist_features is None:
          return statistics
      result = statistics_pb2.DatasetFeatureStatisticsList()
      for dataset_stats in statistics.datasets:
          result_dataset_stats = result.datasets.add()
          result_dataset_stats.MergeFrom(dataset_stats)
          del result_dataset_stats.features[:]
          if allowlist_features is not None:
              allowlist_features = set(allowlist_features)
              for feature in dataset_stats.features:
                  if (
                      types.FeaturePath.from_proto(feature.path)
                      in allowlist_features
                  ):
                      result_dataset_stats.features.add().MergeFrom(
                          feature
                      )
          else:
              denylist_features = set(denylist_features)
              for feature in dataset_stats.features:
                  if (
                      types.FeaturePath.from_proto(feature.path)
                      in denylist_features
                  ):
                      continue
                  result_dataset_stats.features.add().MergeFrom(feature)
      return result
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import base64
  import collections
  import sys
  from typing import Dict, Iterable, List, Optional, Text, Tuple, Union
  import pandas
  from tensorflow_data_validation import types
  from tensorflow_data_validation.skew.protos import feature_skew_results_pb2
  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 7 for calling a global function with example usage: _project_statistics(statistics, allowlist_features, denylist_features) and returns: result, statistics