code: def _weighted_unique(
      values: np.ndarray, weights: np.ndarray
  ) -> Iterator[Tuple[Any, int, Union[int, float]]]:
      """Computes weighted uniques.
  
      Args:
        values: 1-D array.
        weights: 1-D numeric array. Should have the same size as `values`.
      Returns:
        An iterator of tuples (unique_value, count, sum_weight).
  
      Implementation note: we use Pandas and pay the cost of copying the
      input numpy arrays into a DataFrame because Pandas can perform group-by
      without sorting. A numpy-only implementation with sorting is possible but
      slower because of the calls to the string comparator.
      """
      df = pd.DataFrame(
          {
              "value": values,
              "count": np.ones_like(values, dtype=np.int32),
              "weight": weights,
          }
      )
      gb = df.groupby("value", as_index=False, sort=False)[
          ["count", "weight"]
      ].sum()
      return zip(
          gb["value"].tolist(),
          gb["count"].tolist(),
          gb["weight"].tolist(),
      )
  
imports: import logging
  from typing import Any, FrozenSet, Iterable, Iterator, Mapping, Optional, Text, Tuple, Union
  import apache_beam
  import numpy
  import pandas
  import pyarrow
  from tensorflow_data_validation import types
  from tensorflow_data_validation.arrow import arrow_util
  from tensorflow_data_validation.statistics.generators import stats_generator
  from tensorflow_data_validation.utils import schema_util
  from tensorflow_data_validation.utils import stats_util
  from tensorflow_data_validation.utils import top_k_uniques_stats_util
  from tensorflow_data_validation.utils.example_weight_map import ExampleWeightMap
  from tfx_bsl.arrow import array_util
  from tensorflow_metadata.proto.v0 import schema_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: _weighted_unique(values, weights) and returns: zip