code: def detailed_blanc(
      key: ty.Sequence[ty.Set], response: ty.Sequence[ty.Set]
  ) -> ty.Tuple[
      ty.Union[ty.Tuple[float, float, float], None],
      ty.Union[ty.Tuple[float, float, float], None],
  ]:
      """Return BLANC `$(R, P, F)$` scores for coreference and non-coreference respectively."""
  
      # Edge case : a single mention in both `key` and `response` clusters
      # in that case, `C_k`, `C_r`, `N_k` and `N_r` are all empty, so we need a separate examination
      # of the mentions to know if we are very good or very bad.
      if (
          len(key) == len(response) == 1
          and len(key[0]) == len(response[0]) == 1
      ):
          if key[0] == response[0]:
              return ((1.0, 1.0, 1.0), (1.0, 1.0, 1.0))
          else:
              return ((0.0, 0.0, 0.0), (0.0, 0.0, 0.0))
  
      C_k, N_k = links_from_clusters(key)
      C_r, N_r = links_from_clusters(response)
  
      tp_c = len(C_k.intersection(C_r))
      tp_n = len(N_k.intersection(N_r))
      c_k, n_k = len(C_k), len(N_k)
      c_r, n_r = len(C_r), len(N_r)
  
      if not c_k and not c_r:
          R_c, P_c, F_c = (1.0, 1.0, 1.0)
      elif not c_k or not c_r:
          R_c, P_c, F_c = (0.0, 0.0, 0.0)
      else:
          R_c, P_c = tp_c / c_k, tp_c / c_r
          F_c = 2 * tp_c / (c_k + c_r)
  
      if not n_k and not n_r:
          R_n, P_n, F_n = (1.0, 1.0, 1.0)
      elif not n_k or not n_r:
          R_n, P_n, F_n = (0.0, 0.0, 0.0)
      else:
          R_n, P_n = tp_n / n_k, tp_n / n_r
          F_n = 2 * tp_n / (n_k + n_r)
  
      # Edge cases
      if not c_k:
          return (None, (R_n, P_n, F_n))
      if not n_k:
          return ((R_c, P_c, F_c), None)
  
      return ((R_c, P_c, F_c), (R_n, P_n, F_n))
  
file_path: DeepKE/src/deepke/triple_extraction/ASP/metrics/blanc.py
imports: import math
  import typing
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: detailed_blanc(key, response) and returns: R_c,  P_c,  F_c,  R_n,  P_n,  F_n, None,  R_n,  P_n,  F_n, R_c,  P_c,  F_c,  None, int,  int,  int,  int,  int,  int, int,  int,  int,  int,  int,  int