code: def _populate_token_statistics(
      name: Text,
      num_histogram_buckets: int,
      num_examples: int,
      token_proto: statistics_pb2.NaturalLanguageStatistics.TokenStatistics,
      stats: _TokenStats,
  ):
      """Populates the token statistics for a specified token."""
      if isinstance(name, int):
          token_proto.int_token = name
      else:
          token_proto.string_token = name
      if stats.num_sequences:
          token_proto.frequency = stats.frequency
          token_proto.fraction_of_sequences = (
              float(stats.num_sequences) / num_examples
          )
          token_proto.per_sequence_min_frequency = (
              stats.per_sequence_min_frequency
          )
          token_proto.per_sequence_max_frequency = (
              stats.per_sequence_max_frequency
          )
          token_proto.per_sequence_avg_frequency = (
              float(stats.frequency) / stats.num_sequences
          )
          _populate_token_position_histogram(
              token_proto, stats, num_histogram_buckets
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from typing import Dict, Iterable, List, Optional, Set, Text, Union
  import pyarrow
  import six
  from tensorflow_data_validation import types
  from tensorflow_data_validation.statistics.generators import stats_generator
  from tensorflow_data_validation.utils import quantiles_util
  from tensorflow_data_validation.utils import schema_util
  from tensorflow_data_validation.utils import stats_util
  from tensorflow_data_validation.utils import vocab_util
  from tfx_bsl import sketches
  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 12 for calling a global function with example usage: _populate_token_statistics(name, num_histogram_buckets, num_examples, token_proto, stats) without return types