code: def get_valid_statistics(
      statistics: Dict[types.FeaturePath, Dict[Text, np.ndarray]],
      min_partitions_stat_presence: int,
  ) -> Dict[types.FeaturePath, Dict[Text, np.ndarray]]:
      """Filters out statistics that were not computed over all partitions."""
      valid_statistics = collections.defaultdict(
          collections.defaultdict
      )
      for feature_path, feature_statistics in statistics.items():
          for stat_name, stat_values in feature_statistics.items():
              # Only keep statistics that appear min_partitions_stat_presence times
              if len(stat_values) >= min_partitions_stat_presence:
                  valid_statistics[feature_path][stat_name] = np.array(
                      stat_values
                  )
      return valid_statistics
  
imports: import collections
  import functools
  from typing import Dict, Iterable, Text, Tuple
  import apache_beam
  import numpy
  import pyarrow
  from tensorflow_data_validation import constants
  from tensorflow_data_validation import types
  from tensorflow_data_validation.statistics.generators import stats_generator
  from tensorflow_data_validation.utils import stats_util
  from tfx_bsl.arrow import table_util
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 2 for calling a global function with example usage: get_valid_statistics(statistics, min_partitions_stat_presence) and returns: valid_statistics