code: def plot_reliability_diagram(
      calibration_data, predictions, ece=None, filename=None
  ):
      """
      Helper function for plotting a reliability diagram.
  
      .. seealso::
  
         `Examples using calibration <https://stellargraph.readthedocs.io/en/stable/demos/calibration/index.html>`__.
  
         Related functionality: :func:`.expected_calibration_error`, :class:`.IsotonicCalibration`, :class:`.TemperatureCalibration`.
  
      Args:
          calibration_data (list): The calibration data as a list where each entry in the list is a 2-tuple of type
              :class:`numpy.ndarray`. Each entry in the tuple holds the fraction of positives and the mean predicted values
              for the true and predicted class labels.
          predictions (np.ndarray): The probabilistic predictions of the classifier for each sample in the dataset used
              for diagnosing miscalibration.
          ece (None or list of float): If not None, this list stores the expected calibration error for each class.
          filename (str or None): If not None, the figure is saved on disk in the given filename.
      """
      if not isinstance(calibration_data, list):
          raise ValueError(
              "Parameter calibration_data should be list of 2-tuples but received type {}".format(
                  type(calibration_data).__name__
              )
          )
  
      if not isinstance(predictions, np.ndarray):
          raise ValueError(
              "Parameter predictions should be of type numpy.ndarray but received type {}".format(
                  type(predictions).__name__
              )
          )
      if ece is not None and not isinstance(ece, list):
          raise ValueError(
              "Parameter ece should be None or list of floating point numbers but received type {}".format(
                  type(ece).__name__
              )
          )
      if filename is not None and not isinstance(filename, str):
          raise ValueError(
              "Parameter filename should be None or str type but received type {}".format(
                  type(filename).__name__
              )
          )
  
      fig = plt.figure(figsize=(12, 8))
      ax1 = plt.subplot2grid((6, 1), (0, 0), rowspan=3)
      ax2 = plt.subplot2grid((6, 1), (4, 0))
  
      if ece is not None:
          calibration_error = ",".join(format(e, " 0.4f") for e in ece)
  
      for i, data in enumerate(calibration_data):
          fraction_of_positives, mean_predicted_value = data
          # print(fraction_of_positives, mean_predicted_value)
          ax1.plot(
              mean_predicted_value,
              fraction_of_positives,
              "s-",
              alpha=1.0,
          )
          if ece is not None:
              ax1.set_title(
                  "Calibration Curve (ECE={})".format(calibration_error)
              )
          ax1.set_xlabel("Mean Predicted Value", fontsize=16)
          ax1.set_ylabel("Fraction of Positives", fontsize=16)
          ax1.plot([0, 1], [0, 1], "g--")
          ax2.hist(
              predictions[:, i],
              range=(0, 1),
              bins=10,
              histtype="step",
              lw=2,
          )
          ax2.set_xlabel("Bin", fontsize=16)
          ax2.set_ylabel("Count", fontsize=16)
          if filename is not None:
              fig.savefig(filename, bbox_inches="tight")
  
imports: import numpy
  import matplotlib.pyplot
  import tensorflow
  from sklearn.isotonic import IsotonicRegression
  from sklearn.linear_model import LogisticRegression
label_desc: Use image node_id 2 for calling a global function with example usage: plot_reliability_diagram(calibration_data, predictions, ece, filename) without return types