code: def compute_diff(proto_a, proto_b):
      """Returns `ProtoDiff` of two protos, else None if no diffs.
  
      Args:
        proto_a: First of the two protos to compare.
        proto_b: Second of the two protos to compare.
      """
      dict1 = json_format.MessageToDict(
          proto_a, preserving_proto_field_name=True
      )
      dict2 = json_format.MessageToDict(
          proto_b, preserving_proto_field_name=True
      )
      diff = deepdiff.DeepDiff(dict1, dict2, significant_digits=3)
      if diff:
          changed_paths = []
          for key in diff.pop("values_changed", []):
              changed_paths.append(_dict_path_to_proto_path(key))
  
          added_paths = []
          for key in diff.pop("dictionary_item_added", []):
              added_paths.append(_dict_path_to_proto_path(key))
  
          for key in diff.pop("iterable_item_added", []):
              added_paths.append(_dict_path_to_proto_path(key))
  
          removed_paths = []
          for key in diff.pop("dictionary_item_removed", []):
              removed_paths.append(_dict_path_to_proto_path(key))
  
          for key in diff.pop("iterable_item_removed", []):
              removed_paths.append(_dict_path_to_proto_path(key))
  
          if diff:
              raise ValueError("Unhandled diffs: {}".format(diff))
  
          return ProtoDiffs(
              proto_a=proto_a,
              proto_b=proto_b,
              changed=changed_paths,
              added=added_paths,
              removed=removed_paths,
          )
      else:
          return None
  
imports: import deepdiff
  from google.protobuf import json_format
label_desc: Use image node_id 3 for calling a global function with example usage: compute_diff(proto_a, proto_b) and returns: ProtoDiffs, None