code: def _get_token_statistics(
      token_statistic: List[
          statistics_pb2.NaturalLanguageStatistics.TokenStatistics
      ],
  ) -> pd.DataFrame:
      """Returns a dict of each token's stats."""
      nlp_stats_dict = {
          _TOKEN_NAME_KEY: [],
          _FREQUENCY_KEY: [],
          _FRACTION_OF_SEQ_KEY: [],
          _PER_SEQ_MIN_FREQ_KEY: [],
          _PER_SEQ_MAX_FREQ_KEY: [],
          _PER_SEQ_AVG_FREQ_KEY: [],
          _POSITIONS_KEY: [],
      }
      for token in token_statistic:
          if token.WhichOneof("token") == "string_token":
              token_name = token.string_token
          else:
              token_name = token.int_token
          nlp_stats_dict[_TOKEN_NAME_KEY].append(token_name)
          nlp_stats_dict[_FREQUENCY_KEY].append(token.frequency)
          nlp_stats_dict[_FRACTION_OF_SEQ_KEY].append(
              token.fraction_of_sequences
          )
          nlp_stats_dict[_PER_SEQ_MIN_FREQ_KEY].append(
              token.per_sequence_min_frequency
          )
          nlp_stats_dict[_PER_SEQ_MAX_FREQ_KEY].append(
              token.per_sequence_max_frequency
          )
          nlp_stats_dict[_PER_SEQ_AVG_FREQ_KEY].append(
              token.per_sequence_avg_frequency
          )
          nlp_stats_dict[_POSITIONS_KEY].append(
              _get_histogram_dataframe(token.positions)
          )
      return pd.DataFrame.from_dict(nlp_stats_dict)
  
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 15 for calling a global function with example usage: _get_token_statistics(token_statistic) and returns: pd