code: def get_average_and_joint_goal_accuracy(
      frame_ref, frame_hyp, service, use_fuzzy_match
  ):
      """Get average and joint goal accuracies of a frame.
  
      Args:
        frame_ref: single semantic frame from reference (ground truth) file.
        frame_hyp: single semantic frame from hypothesis (prediction) file.
        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 comparing
          non-categorical slot values.
  
      Returns:
        goal_acc: a dict whose values are average / joint
            all-goal / categorical-goal / non-categorical-goal accuracies.
      """
      goal_acc = {}
  
      (
          list_acc,
          slot_active,
          slot_cat,
          list_status_acc,
          list_value_acc,
      ) = compare_slot_values(
          frame_ref["state"]["slot_values"],
          frame_hyp["state"]["slot_values"],
          service,
          use_fuzzy_match,
      )
  
      # (4) Average goal accuracy.
      active_acc = [
          acc for acc, active in zip(list_acc, slot_active) if active
      ]
      goal_acc[AVERAGE_GOAL_ACCURACY] = (
          np.mean(active_acc) if active_acc else NAN_VAL
      )
      # (4-a) categorical.
      active_cat_acc = [
          acc
          for acc, active, cat in zip(list_acc, slot_active, slot_cat)
          if active and cat
      ]
      goal_acc[AVERAGE_CAT_ACCURACY] = (
          np.mean(active_cat_acc) if active_cat_acc else NAN_VAL
      )
      # (4-b) non-categorical.
      active_noncat_acc = [
          acc
          for acc, active, cat in zip(list_acc, slot_active, slot_cat)
          if active and not cat
      ]
      goal_acc[AVERAGE_NONCAT_ACCURACY] = (
          np.mean(active_noncat_acc) if active_noncat_acc else NAN_VAL
      )
  
      # (5) Joint goal accuracy.
      goal_acc[JOINT_GOAL_ACCURACY] = (
          np.prod(list_acc) if list_acc else NAN_VAL
      )
      # (5-a) categorical.
      cat_acc = [acc for acc, cat in zip(list_acc, slot_cat) if cat]
      goal_acc[JOINT_CAT_ACCURACY] = (
          np.prod(cat_acc) if cat_acc else NAN_VAL
      )
      # (5-b) non-categorical.
      noncat_acc = [
          acc for acc, cat in zip(list_acc, slot_cat) if not cat
      ]
      goal_acc[JOINT_NONCAT_ACCURACY] = (
          np.prod(noncat_acc) if noncat_acc else NAN_VAL
      )
  
      # !!!!!!!!!!DEBUG!!!!!!!!!!!!!
      # cat status acc for both active and non active
      active_cat_status_acc = [
          acc
          for acc, active, cat in zip(
              list_status_acc, slot_active, slot_cat
          )
          if cat and active
      ]
      goal_acc[AVERAGE_CAT_STATUS_ACCURACY] = (
          np.mean(active_cat_status_acc)
          if active_cat_status_acc
          else NAN_VAL
      )
      # joint cat status acc for both active and non active
      cat_status_acc = [
          acc for acc, cat in zip(list_status_acc, slot_cat) if cat
      ]
      goal_acc[JOINT_CAT_STATUS_ACCURACY] = (
          np.prod(cat_status_acc) if cat_status_acc else NAN_VAL
      )
  
      # non cat status acc for both active and non active
      active_noncat_status_acc = [
          acc
          for acc, active, cat in zip(
              list_status_acc, slot_active, slot_cat
          )
          if not cat and active
      ]
      goal_acc[AVERAGE_NONCAT_STATUS_ACCURACY] = (
          np.mean(active_noncat_status_acc)
          if active_noncat_status_acc
          else NAN_VAL
      )
      # joint non cat status acc for both active and non active
      noncat_status_acc = [
          acc for acc, cat in zip(list_status_acc, slot_cat) if not cat
      ]
      goal_acc[JOINT_NONCAT_STATUS_ACCURACY] = (
          np.prod(noncat_status_acc) if noncat_status_acc else NAN_VAL
      )
  
      # cat value acc for both active and non active
      active_cat_val_acc = [
          acc
          for acc, active, cat in zip(
              list_value_acc, slot_active, slot_cat
          )
          if cat and acc > -0.5 and active
      ]
      goal_acc[AVERAGE_CAT_VALUE_ACCURACY] = (
          np.mean(active_cat_val_acc) if active_cat_val_acc else NAN_VAL
      )
      # joint cat value acc for both active and non active
      cat_val_acc = [
          acc
          for acc, cat in zip(list_value_acc, slot_cat)
          if cat and acc > -0.5
      ]
      goal_acc[JOINT_CAT_VALUE_ACCURACY] = (
          np.prod(cat_val_acc) if cat_val_acc else NAN_VAL
      )
  
      # cat non value acc for both active and non active
      active_noncat_val_acc = [
          acc
          for acc, active, cat in zip(
              list_value_acc, slot_active, slot_cat
          )
          if not cat and acc > -0.5 and active
      ]
      goal_acc[AVERAGE_NONCAT_VALUE_ACCURACY] = (
          np.mean(active_noncat_val_acc)
          if active_noncat_val_acc
          else NAN_VAL
      )
      # joint non cat value acc for both active and non active
      noncat_val_acc = [
          acc
          for acc, cat in zip(list_value_acc, slot_cat)
          if not cat and acc > -0.5
      ]
      goal_acc[JOINT_NONCAT_VALUE_ACCURACY] = (
          np.prod(noncat_val_acc) if noncat_val_acc else NAN_VAL
      )
  
      return goal_acc
  
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 8 for calling a global function with example usage: get_average_and_joint_goal_accuracy(frame_ref, frame_hyp, service, use_fuzzy_match) and returns: goal_acc