code: def test_extract_graph_data_from_slicing_metrics(self):
      slicing_metrics = [
          (
              (("weekday", 0),),
              {
                  "": {
                      "": {
                          "average_loss": {
                              "doubleValue": 0.07875693589448929
                          },
                          "prediction/mean": {
                              "boundedValue": {
                                  "value": 0.5100112557411194,
                                  "lowerBound": 0.4100112557411194,
                                  "upperBound": 0.6100112557411194,
                              }
                          },
                      }
                  }
              },
          ),
          (
              (("weekday", 1),),
              {
                  "": {
                      "": {
                          "average_loss": {
                              "doubleValue": 4.4887189865112305
                          },
                          "prediction/mean": {
                              "boundedValue": {
                                  "value": 0.4839990735054016,
                                  "lowerBound": 0.3839990735054016,
                                  "upperBound": 0.5839990735054016,
                              }
                          },
                      }
                  }
              },
          ),
          (
              (("weekday", 2),),
              {
                  "": {
                      "": {
                          "average_loss": {
                              "doubleValue": 2.092138290405273
                          },
                          "prediction/mean": {
                              "doubleValue": 0.3767518997192383
                          },
                          "__ERROR__": {
                              # CI not computed because only 16 samples
                              # were non-empty. Expected 20.
                              "bytesValue": "Q0kgbm90IGNvbXB1dGVkIGJlY2F1c2Ugb25seSAxNiBzYW1wbGVzIHdlcmUgbm9uLWVtcHR5LiBFeHBlY3RlZCAyMC4="  # pylint: disable=line-too-long
                          },
                      }
                  }
              },
          ),
          (
              (),
              {
                  "": {
                      "": {
                          "average_loss": {
                              "doubleValue": 1.092138290405273
                          },
                          "prediction/mean": {
                              "boundedValue": {
                                  "value": 0.4767518997192383,
                                  "lowerBound": 0.2767518997192383,
                                  "upperBound": 0.6767518997192383,
                              }
                          },
                      }
                  }
              },
          ),
      ]
      self.assertGraphEqual(
          tf_graphics._extract_graph_data_from_slicing_metrics(
              slicing_metrics, "average_loss"
          ),
          graphics.Graph(
              x=[
                  0.07875693589448929,
                  4.4887189865112305,
                  2.092138290405273,
                  1.092138290405273,
              ],
              y=["0", "1", "2", "Overall"],
              xlabel="average_loss",
              ylabel="slices",
              title="average_loss",
              name="average_loss",
              color="#A142F4",
          ),
      )
      self.assertGraphEqual(
          tf_graphics._extract_graph_data_from_slicing_metrics(
              slicing_metrics, "average_loss", "weekday"
          ),
          graphics.Graph(
              x=[
                  0.07875693589448929,
                  4.4887189865112305,
                  2.092138290405273,
                  1.092138290405273,
              ],
              y=["0", "1", "2", "Overall"],
              xlabel="average_loss",
              ylabel="slices",
              title="average_loss | weekday",
              name="average_loss | weekday",
              color="#A142F4",
          ),
      )
      self.assertGraphEqual(
          tf_graphics._extract_graph_data_from_slicing_metrics(
              slicing_metrics, "prediction/mean"
          ),
          graphics.Graph(
              x=[
                  0.5100112557411194,
                  0.4839990735054016,
                  0.3767518997192383,
                  0.4767518997192383,
              ],
              y=["0", "1", "2", "Overall"],
              xerr=[
                  [0.09999999999999998, 0.10000000000000003, 0, 0.2],
                  [0.09999999999999998, 0.09999999999999998, 0, 0.2],
              ],
              xlabel="prediction/mean",
              ylabel="slices",
              title="prediction/mean",
              name="prediction/mean",
              color="#A142F4",
          ),
      )
  
      self.assertGraphEqual(
          tf_graphics._extract_graph_data_from_slicing_metrics(
              slicing_metrics, "prediction/mean", "weekday"
          ),
          graphics.Graph(
              x=[
                  0.5100112557411194,
                  0.4839990735054016,
                  0.3767518997192383,
                  0.4767518997192383,
              ],
              y=["0", "1", "2", "Overall"],
              xerr=[
                  [0.09999999999999998, 0.10000000000000003, 0, 0.2],
                  [0.09999999999999998, 0.09999999999999998, 0, 0.2],
              ],
              xlabel="prediction/mean",
              ylabel="slices",
              title="prediction/mean | weekday",
              name="prediction/mean | weekday",
              color="#A142F4",
          ),
      )
  
file_path: model-card-toolkit/model_card_toolkit/utils/tf_graphics_test.py
imports: import logging
  import tensorflow_model_analysis
  from absl.testing import absltest
  from google.protobuf import text_format
  from tensorflow_metadata.proto.v0 import statistics_pb2
  from model_card_toolkit import model_card
  from model_card_toolkit.utils import graphics, tf_graphics
label_desc: Use image node_id 4 for calling the TfGraphicsTest obj's underlying member method code with example usage: obj.test_extract_graph_data_from_slicing_metrics() without return types