code: def testQuantilesPerKey(self):
      def analyzer_fn(inputs):
          (
              key_vocab,
              q_b,
              scale_factor_per_key,
              shift_per_key,
              num_buckets,
          ) = analyzers._quantiles_per_key(
              inputs["x"], inputs["key"], num_buckets=3, epsilon=0.00001
          )
          return {
              "key_vocab": key_vocab,
              "q_b": q_b,
              "scale_factor_per_key": scale_factor_per_key,
              "shift_per_key": shift_per_key,
              "num_buckets": num_buckets,
          }
  
      # NOTE: We force 10 batches: data has 100 elements and we request a batch
      # size of 10.
      input_data = [
          {"x": [x], "key": "a" if x < 50 else "b"}
          for x in range(1, 100)
      ]
      input_metadata = tft.DatasetMetadata.from_feature_spec(
          {
              "x": tf.io.FixedLenFeature([1], tf.int64),
              "key": tf.io.FixedLenFeature([], tf.string),
          }
      )
      # The expected data has 2 boundaries that divides the data into 3 buckets.
      expected_outputs = {
          "key_vocab": np.array([b"a", b"b"], object),
          "q_b": np.array([0.0, 1.0, 2.0], np.float32),
          "scale_factor_per_key": np.array(
              [0.0625, 0.05882353], np.float32
          ),
          "shift_per_key": np.array([-1.0625, -2.88235283], np.float32),
          "num_buckets": np.array(3, np.int64),
      }
      self.assertAnalyzerOutputs(
          input_data,
          input_metadata,
          analyzer_fn,
          expected_outputs,
          desired_batch_size=10,
      )
  
imports: import contextlib
  import random
  import numpy
  import tensorflow
  import tensorflow_transform
  from tensorflow_transform import analyzers
  from tensorflow_transform.beam import impl
  from tensorflow_transform.beam import tft_unit
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 9 for calling the BucketizeIntegrationTest obj's underlying member method code with example usage: obj.testQuantilesPerKey() and returns: dict