code: def fast_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))
  
      (key, response), mentions_map = remap_clusterings([key, response])
      num_mentions = len(mentions_map)
  
      key_coref_links, key_presence = adjacency(key, num_mentions)
      response_coref_links, response_presence = adjacency(
          response, num_mentions
      )
  
      tp_c = (
          np.logical_and(key_coref_links, response_coref_links).sum()
          // 2
      )
      c_k = key_coref_links.sum() // 2
      c_r = response_coref_links.sum() // 2
  
      # Headache ahead
      common_links = np.logical_and(
          np.outer(key_presence, key_presence),
          np.outer(response_presence, response_presence),
      )
      # There is no link between a mention and itself
      np.fill_diagonal(common_links, False)
      tp_n = (
          np.logical_and(
              common_links,
              np.logical_not(
                  np.logical_or(key_coref_links, response_coref_links)
              ),
          ).sum()
          / 2
      )
      num_key_mentions = key_presence.sum()
      n_k = (num_key_mentions * (num_key_mentions - 1)) // 2 - c_k
      num_response_mentions = response_presence.sum()
      n_r = (
          num_response_mentions * (num_response_mentions - 1)
      ) // 2 - c_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 ((tp_c, c_k, c_r), (tp_n, n_k, n_r))
  
file_path: DeepKE/src/deepke/triple_extraction/ASP/metrics/blanc.py
imports: import math
  import typing
  import numpy
label_desc: Use image node_id 7 for calling a global function with example usage: fast_detailed_blanc(key, response) and returns: tp_c,  c_k,  c_r,  tp_n,  n_k,  n_r, int,  int,  int,  int,  int,  int, int,  int,  int,  int,  int,  int