class_docstr: Metric Parser for clarify explainability
class_docstr_tok: ["Metric","Parser","for","clarify","explainability"]
docstr: Parse kernal_shap data in clarify explainability.
  
  Args:
      explains (dict): Explains metric data.
docstr_tok: ["Parse","kernal_shap","data","in","clarify","explainability",".","Args",":","explains","(","dict",")",":","Explains","metric","data","."]
code: def _parse_kernal_shap(self, explains: dict):
      """Parse kernal_shap data in clarify explainability.
  
      Args:
          explains (dict): Explains metric data.
      """
  
      def format_group(group_name: str, group_data: dict):
          """Create the metric group entry.
  
          Args:
              group_name (str): Metric group name.
              group_data (dict): Raw metric group data.
          """
          metric_data = [
              {
                  "name": k,
                  "value": v,
                  "type": PYTHON_TYPE_TO_METRIC_VALUE_TYPE[
                      type(v)
                  ].value,
              }
              for k, v in group_data.items()
          ]
          metric_group = {
              "name": group_name,
              "metric_data": metric_data,
          }
  
          return metric_group
  
      metric_groups = []
      if "kernel_shap" not in explains:
          return metric_groups
  
      for label_name, explain in explains["kernel_shap"].items():
          for key1, value1 in explain.items():
              if key1 == "global_shap_values":
                  group_name = (
                      f"explanations - {key1}, label={label_name}"
                  )
                  metric_groups.append(format_group(group_name, value1))
              if key1 == "global_top_shap_text":
                  for feature_name, feature_data in value1.items():
                      group_name = (
                          f"explanations - {key1}, label={label_name}, "
                          f"feature={feature_name}"
                      )
                      metric_groups.append(
                          format_group(group_name, feature_data)
                      )
  
      return metric_groups
  
imports: from __future__ import absolute_import
  from abc import ABC, abstractmethod
  from enum import Enum
  from collections import defaultdict
  from typing import Union, List
  from sagemaker.model_card.schema_constraints import PYTHON_TYPE_TO_METRIC_VALUE_TYPE, METRIC_VALUE_TYPE_MAP, MetricTypeEnum
label_desc: Use image node_id 3 for calling the ClarifyExplainabilityParser obj's underlying member method code with example usage: obj._parse_kernal_shap(explains) and returns: metric_groups, metric_group, metric_groups