class_docstr: A class to store counterfactual examples for one or more inputs
  and feature importance scores.
  
  :param cf_examples_list: A list of CounterfactualExamples instances
  :param local_importance: List of estimated local importance scores. The
      size of the list is the number of input instances, each containing
      feature importance scores for that input.
  :param summary_importance: Estimated global feature importance scores
      based on the input set of CounterfactualExamples instances
docstr: Deserialize json string to a CounterfactualExplanations object.
          
docstr_tok: ["Deserialize","json","string","to","a","CounterfactualExplanations","object","."]
code: def from_json(json_str):
      """Deserialize json string to a CounterfactualExplanations object."""
      json_dict = json.loads(json_str)
      if _CommonSchemaConstants.METADATA in json_dict:
          version = json_dict[_CommonSchemaConstants.METADATA].get(
              "version"
          )
          CounterfactualExplanations._validate_serialization_version(
              version
          )
  
          if version == _SchemaVersions.V1:
              CounterfactualExplanations._check_cf_exp_output_against_json_schema(
                  json_dict, version=version
              )
              cf_examples_list = []
              for cf_examples_str in json_dict[
                  _CounterfactualExpV1SchemaConstants.CF_EXAMPLES_LIST
              ]:
                  cf_examples_list.append(
                      CounterfactualExamples.from_json(cf_examples_str)
                  )
  
              return CounterfactualExplanations(
                  cf_examples_list=cf_examples_list,
                  local_importance=json_dict[
                      _CounterfactualExpV1SchemaConstants.LOCAL_IMPORTANCE
                  ],
                  summary_importance=json_dict[
                      _CounterfactualExpV1SchemaConstants.SUMMARY_IMPORTANCE
                  ],
                  version=version,
              )
          else:
              CounterfactualExplanations._check_cf_exp_output_against_json_schema(
                  json_dict, version=version
              )
              cf_examples_list = []
              for index in range(
                  0,
                  len(
                      json_dict[
                          _CounterfactualExpV2SchemaConstants.CFS_LIST
                      ]
                  ),
              ):
                  # We need to save the json again since we need to recompose the
                  # counterfactual example.
                  cf_examples_str = json.dumps(
                      {
                          _DiverseCFV2SchemaConstants.FINAL_CFS_LIST: json_dict[
                              _CounterfactualExpV2SchemaConstants.CFS_LIST
                          ][
                              index
                          ],
                          _DiverseCFV2SchemaConstants.TEST_INSTANCE_LIST: json_dict[
                              _CounterfactualExpV2SchemaConstants.TEST_DATA
                          ][
                              index
                          ],
                          _DiverseCFV2SchemaConstants.DATA_INTERFACE: json_dict[
                              _CounterfactualExpV2SchemaConstants.DATA_INTERFACE
                          ],
                          _DiverseCFV2SchemaConstants.DESIRED_CLASS: json_dict[
                              _CounterfactualExpV2SchemaConstants.DESIRED_CLASS
                          ],
                          _DiverseCFV2SchemaConstants.DESIRED_RANGE: json_dict[
                              _CounterfactualExpV2SchemaConstants.DESIRED_RANGE
                          ],
                          _DiverseCFV2SchemaConstants.MODEL_TYPE: json_dict[
                              _CounterfactualExpV2SchemaConstants.MODEL_TYPE
                          ],
                          _DiverseCFV2SchemaConstants.FEATURE_NAMES_INCLUDING_TARGET: json_dict[
                              _CounterfactualExpV2SchemaConstants.FEATURE_NAMES_INCLUDING_TARGET
                          ],
                      }
                  )
                  cf_examples_list.append(
                      CounterfactualExamples.from_json(cf_examples_str)
                  )
  
              local_importance_list = None
              if (
                  json_dict[
                      _CounterfactualExpV2SchemaConstants.LOCAL_IMPORTANCE
                  ]
                  is not None
              ):
                  local_importance_list = []
                  for local_importance_instance in json_dict[
                      _CounterfactualExpV2SchemaConstants.LOCAL_IMPORTANCE
                  ]:
                      local_importance_dict = {}
                      feature_names = json_dict[
                          _CounterfactualExpV2SchemaConstants.FEATURE_NAMES
                      ]
                      for index in range(
                          0, len(local_importance_instance)
                      ):
                          local_importance_dict[
                              feature_names[index]
                          ] = local_importance_instance[index]
                      local_importance_list.append(
                          local_importance_dict
                      )
  
              summary_importance_dict = None
              if (
                  json_dict[
                      _CounterfactualExpV2SchemaConstants.SUMMARY_IMPORTANCE
                  ]
                  is not None
              ):
                  summary_importance_dict = {}
                  feature_names = json_dict[
                      _CounterfactualExpV2SchemaConstants.FEATURE_NAMES
                  ]
                  for index in range(
                      0,
                      len(
                          json_dict[
                              _CounterfactualExpV2SchemaConstants.SUMMARY_IMPORTANCE
                          ]
                      ),
                  ):
                      summary_importance_dict[
                          feature_names[index]
                      ] = json_dict[
                          _CounterfactualExpV2SchemaConstants.SUMMARY_IMPORTANCE
                      ][
                          index
                      ]
  
              return CounterfactualExplanations(
                  cf_examples_list=cf_examples_list,
                  local_importance=local_importance_list,
                  summary_importance=summary_importance_dict,
                  version=version,
              )
      else:
          return json_dict
  
imports: import json
  import os
  import jsonschema
  from raiutils.exceptions import UserConfigValidationException
  from dice_ml.constants import _SchemaVersions
  from dice_ml.diverse_counterfactuals import CounterfactualExamples, _DiverseCFV2SchemaConstants
label_desc: Use image node_id 12 for calling the CounterfactualExplanations obj's underlying member method code with example usage: obj.from_json(json_str) and returns: json_dict, CounterfactualExplanations, CounterfactualExplanations