code: def _sort_and_truncate_reported_sequence(
      sequence: List[_ReportedSequence],
  ):
      sequence.sort(key=lambda x: x.metric)
      deduped_values = []
      hash_values = set()
      for s in sequence:
          if s.hash_value in hash_values:
              continue
          hash_values.add(s.hash_value)
          deduped_values.append(s)
      return deduped_values[:_NUM_REPORTED_SEQUENCES_PER_TYPE]
  
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 1 for calling a global function with example usage: _sort_and_truncate_reported_sequence(sequence) and returns: deduped_values