code: def result_to_proto(result):
      """Given a result dict, convert it to a tcav.Result proto.
  
      Args:
        result: a dictionary returned by tcav._run_single_set()
  
      Returns:
        TCAV.Result proto
      """
      result_proto = Result()
      for key in _KEYS:
          setattr(result_proto, key, result[key])
      positive_set_name = result["cav_concept"]
      negative_set_name = result["negative_concept"]
      for val in result["val_directional_dirs"]:
          result_proto.val_directional_dirs.append(val)
      result_proto.cav_accuracies.positive_set_accuracy = result[
          "cav_accuracies"
      ][positive_set_name]
      result_proto.cav_accuracies.negative_set_accuracy = result[
          "cav_accuracies"
      ][negative_set_name]
      result_proto.cav_accuracies.overall_accuracy = result[
          "cav_accuracies"
      ]["overall"]
      return result_proto
  
file_path: tcav/tcav/utils.py
imports: from scipy.stats import ttest_ind
  import numpy
  import tensorflow
  from tcav.tcav_results.results_pb2 import Result, Results
label_desc: Use image node_id 8 for calling a global function with example usage: result_to_proto(result) and returns: result_proto