code: def testRebinWithSparseData(self):
      histogram = [
          calibration_histogram.Bucket(4, 5.0, 0.25, 5.0),  # pred = .05
          calibration_histogram.Bucket(
              61, 60.0, 36.0, 60.0
          ),  # pred = .6
          calibration_histogram.Bucket(
              70, 69.0, 47.61, 69.0
          ),  # pred = .69
          calibration_histogram.Bucket(
              100, 99.0, 98.01, 99.0
          ),  # pred = .99
      ]
      # [0, 0.1, ..., 0.9, 1.0]
      thresholds = [i * 1.0 / 10 for i in range(0, 11)]
      got = calibration_histogram.rebin(thresholds, histogram, 100)
  
      expected = [
          calibration_histogram.Bucket(0, 5.0, 0.25, 5.0),
          calibration_histogram.Bucket(1, 0.0, 0.0, 0.0),
          calibration_histogram.Bucket(2, 0.0, 0.0, 0.0),
          calibration_histogram.Bucket(3, 0.0, 0.0, 0.0),
          calibration_histogram.Bucket(4, 0.0, 0.0, 0.0),
          calibration_histogram.Bucket(5, 0.0, 0.0, 0.0),
          calibration_histogram.Bucket(6, 129.0, 83.61, 129.0),
          calibration_histogram.Bucket(7, 0.0, 0.0, 0.0),
          calibration_histogram.Bucket(8, 0.0, 0.0, 0.0),
          calibration_histogram.Bucket(9, 99.0, 98.01, 99.0),
          calibration_histogram.Bucket(10, 0.0, 0.0, 0.0),
      ]
      self.assertLen(got, len(expected))
      for i in range(len(got)):
          self.assertSequenceAlmostEqual(
              dataclasses.astuple(got[i]),
              dataclasses.astuple(expected[i]),
          )
  
file_path: model-analysis/tensorflow_model_analysis/metrics/calibration_histogram_test.py
imports: import dataclasses
  import apache_beam
  from apache_beam.testing import util
  import numpy
  import tensorflow
  from tensorflow_model_analysis.eval_saved_model import testutil
  from tensorflow_model_analysis.metrics import calibration_histogram
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
label_desc: Use image node_id 5 for calling the CalibrationHistogramTest obj's underlying member method code with example usage: obj.testRebinWithSparseData() without return types