code: def compute_wer(df_or_dict):
      if isinstance(df_or_dict, dict):
          wer = (
              df_or_dict["substitutions"]
              + df_or_dict["deletions"]
              + df_or_dict["insertions"]
          ) / (
              df_or_dict["substitutions"]
              + df_or_dict["deletions"]
              + df_or_dict["hits"]
          )
      elif isinstance(df_or_dict, pd.DataFrame):
          wer = (
              df_or_dict["substitutions"].sum()
              + df_or_dict["deletions"].sum()
              + df_or_dict["insertions"].sum()
          ) / (
              df_or_dict["substitutions"].sum()
              + df_or_dict["deletions"].sum()
              + df_or_dict["hits"].sum()
          )
      else:
          raise NotImplementedError
  
      return wer
  
imports: import argparse
  import glob
  import json
  import os
  import pickle
  import warnings
  from collections import OrderedDict
  from copy import deepcopy
  from pathlib import Path
  from typing import Dict, Optional
  import jiwer
  import pandas
  from pyannote.core.utils.types import Label
  from pyannote.metrics.diarization import DiarizationErrorRate
  from pyannote.metrics.errors.identification import IdentificationErrorAnalysis
  from pyannote.metrics.identification import IdentificationErrorRate
  from pyannote.metrics.matcher import HungarianMapper
  from pyannote.metrics.segmentation import Annotation, Segment, Timeline
  from pyannote.metrics.types import MetricComponents
  from tabulate import tabulate
  from tqdm import tqdm
label_desc: Use image node_id 3 for calling a global function with example usage: compute_wer(df_or_dict) and returns: wer