code: def adjacency(
      clusters: ty.List[ty.List[int]], num_elts: int
  ) -> AdjacencyReturn:
      adjacency = np.zeros((num_elts, num_elts), dtype=np.bool)
      presence = np.zeros(num_elts, dtype=np.bool)
      # **Note** The nested loop makes the complexity of this `$∑|c|²$` but we are only doing memory
      # access, which is really fast, so this is not really an issue. In comparison, doing it by
      # computing the Gram matrix one-hot elt-cluster attribution matrix was making `fast_blanc` 3×
      # slower than the naïve version.
      for c in clusters:
          # Note: don't be clever and use numpy array indicing here, see
          # <https://docs.scipy.org/doc/numpy/user/basics.indexing.html?highlight=slice#assigning-values-to-indexed-arrays>
          # for why it would be slower. If you want to get C loops here, cythonize it instead (nut
          # it's probably not worth it)
          for e in c:
              presence[e] = True
              for f in c:
                  if f != e:
                      adjacency[e, f] = True
      return AdjacencyReturn(adjacency, presence)
  
file_path: DeepKE/src/deepke/triple_extraction/ASP/metrics/blanc.py
imports: import math
  import typing
  import numpy
label_desc: Use image node_id 6 for calling a global function with example usage: adjacency(clusters, num_elts) and returns: AdjacencyReturn