code: def testBucketizePerKeyWithInfrequentKeys(self):
      def preprocessing_fn(inputs):
          x_bucketized = tft.bucketize_per_key(
              inputs["x"], inputs["key"], num_buckets=4, epsilon=0.00001
          )
          return {"x": inputs["x"], "x_bucketized": x_bucketized}
  
      input_data = [
          {"x": [], "key": []},
          {"x": [5, 6], "key": ["a", "a"]},
          {"x": [7], "key": ["a"]},
          {"x": [12], "key": ["b"]},
          {"x": [13], "key": ["b"]},
          {"x": [15], "key": ["c"]},
          {"x": [2], "key": ["d"]},
          {"x": [4], "key": ["d"]},
          {"x": [6], "key": ["d"]},
          {"x": [8], "key": ["d"]},
          {"x": [2], "key": ["e"]},
          {"x": [4], "key": ["e"]},
          {"x": [6], "key": ["e"]},
          {"x": [8], "key": ["e"]},
          {"x": [10], "key": ["e"]},
          {"x": [11], "key": ["e"]},
          {"x": [12], "key": ["e"]},
          {"x": [13], "key": ["e"]},
      ]  # pyformat: disable
      input_metadata = tft.DatasetMetadata.from_feature_spec(
          {
              "x": tf.io.VarLenFeature(tf.float32),
              "key": tf.io.VarLenFeature(tf.string),
          }
      )
      expected_data = [
          {"x": [], "x_bucketized": []},
          {"x": [5, 6], "x_bucketized": [1, 2]},
          {"x": [7], "x_bucketized": [3]},
          {"x": [12], "x_bucketized": [1]},
          {"x": [13], "x_bucketized": [3]},
          {"x": [15], "x_bucketized": [1]},
          {"x": [2], "x_bucketized": [0]},
          {"x": [4], "x_bucketized": [1]},
          {"x": [6], "x_bucketized": [2]},
          {"x": [8], "x_bucketized": [3]},
          {"x": [2], "x_bucketized": [0]},
          {"x": [4], "x_bucketized": [0]},
          {"x": [6], "x_bucketized": [1]},
          {"x": [8], "x_bucketized": [1]},
          {"x": [10], "x_bucketized": [2]},
          {"x": [11], "x_bucketized": [2]},
          {"x": [12], "x_bucketized": [3]},
          {"x": [13], "x_bucketized": [2]},
      ]  # pyformat: disable
      expected_metadata = tft.DatasetMetadata.from_feature_spec(
          {
              "x": tf.io.VarLenFeature(tf.float32),
              "x_bucketized": tf.io.VarLenFeature(tf.int64),
          },
          {
              "x_bucketized": schema_pb2.IntDomain(
                  min=0, max=3, is_categorical=True
              ),
          },
      )
      self.assertAnalyzeAndTransformResults(
          input_data,
          input_metadata,
          preprocessing_fn,
          expected_data,
          expected_metadata,
          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 11 for calling the BucketizeIntegrationTest obj's underlying member method code with example usage: obj.testBucketizePerKeyWithInfrequentKeys() and returns: dict