code: def _update_accumulator_with_token_statistics(
      accumulator: _PartialNLStats,
      row: List[Union[int, Text]],
      tokens: Union[Set[int], Set[Text]],
      num_histogram_buckets,
  ):
      """Compute token statistics for a specific row."""
      for t in tokens:
          norm_indices = [
              float(i) / len(row) for i, v in enumerate(row) if v == t
          ]
          num_occur = len(norm_indices)
          accumulator.token_statistics[t].frequency += num_occur
          accumulator.token_statistics[t].num_sequences += (
              1 if num_occur else 0
          )
          for attr, fn in [
              ("per_sequence_min_frequency", min),
              ("per_sequence_max_frequency", max),
          ]:
              accum_freq = getattr(
                  accumulator.token_statistics[t], attr
              )
              if accum_freq is not None:
                  setattr(
                      accumulator.token_statistics[t],
                      attr,
                      fn(accum_freq, num_occur),
                  )
              else:
                  setattr(
                      accumulator.token_statistics[t], attr, num_occur
                  )
          for i in norm_indices:
              accumulator.token_statistics[t].positions[
                  int(i * num_histogram_buckets)
              ] += 1
  
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 3 for calling a global function with example usage: _update_accumulator_with_token_statistics(accumulator, row, tokens, num_histogram_buckets) without return types