code: def compare_slot_values(
      slot_values_ref, slot_values_hyp, service, use_fuzzy_match
  ):
      """Compare and get correctness of goal state's slot_values.
  
      Args:
        slot_values_ref: goal state slot_values from reference (ground truth).
        slot_values_hyp: goal state slot_values from hypothesis (prediction).
        service: a service data structure in the schema. We use it to obtain the
          list of slots in the service and infer whether a slot is categorical.
        use_fuzzy_match: whether to use fuzzy string matching for non-categorical
          slot values
  
      Returns:
        list_cor: list of corectness scores, each corresponding to one slot in the
            service. The score is a float either 0.0 or 1.0 for categorical slot,
            and in range [0.0, 1.0] for non-categorical slot.
        slot_active: list indicating whether the element in list_cor corresponds to
            an active ground-truth slot.
        slot_cat: list indicating whether the element in list_cor corresponds to a
            categorical slot.
        list_cor_status: list of correct slot statuses
        list_cor_value: list of correctness score only for active slots. Monactive slots are assigned -1.
      """
      list_cor = []
      list_cor_status = []
      list_cor_value = []
      slot_active = []
      slot_cat = []
  
      for slot in service["slots"]:
          slot_name = slot["name"]
          slot_cat.append(slot["is_categorical"])
  
          if slot_name in slot_values_ref:  # REF=active
              slot_active.append(True)
              if (
                  slot_name in slot_values_hyp
              ):  # HYP=active, apply matching
                  value_ref_list = slot_values_ref[slot_name]
                  value_hyp = slot_values_hyp[slot_name][0]
                  if slot["is_categorical"]:
                      cor = float(value_ref_list[0] == value_hyp)
                  else:
                      cor = noncat_slot_value_match(
                          value_ref_list, value_hyp, use_fuzzy_match
                      )
                  list_cor.append(cor)
                  list_cor_status.append(1.0)
                  list_cor_value.append(cor)
              else:  # HYP=off
                  list_cor.append(0.0)
                  list_cor_status.append(0.0)
                  list_cor_value.append(-1.0)
          else:  # REF=off
              slot_active.append(False)
              if slot_name in slot_values_hyp:  # HYP=active
                  list_cor.append(0.0)
                  list_cor_status.append(0.0)
              else:  # HYP=off
                  list_cor.append(1.0)
                  list_cor_status.append(1.0)
              list_cor_value.append(-1.0)
  
      assert len(list_cor) == len(service["slots"])
      assert len(slot_active) == len(service["slots"])
      assert len(slot_cat) == len(service["slots"])
      return (
          list_cor,
          slot_active,
          slot_cat,
          list_cor_status,
          list_cor_value,
      )
  
file_path: NeMo/nemo/collections/nlp/metrics/sgd_metrics.py
imports: import collections
  import numpy
  from rapidfuzz import fuzz
label_desc: Use image node_id 4 for calling a global function with example usage: compare_slot_values(slot_values_ref, slot_values_hyp, service, use_fuzzy_match) and returns: list_cor,  slot_active,  slot_cat,  list_cor_status,  list_cor_value