code: def _congruence_coefficient_slow(A, B, absolute_value):
      _, r = tl.shape(A)
      corr_matrix = _tucker_congruence(A, B)
      if absolute_value:
          corr_matrix = tl.abs(corr_matrix)
      corr_matrix = tl.to_numpy(corr_matrix)
  
      best_corr = None
      best_permutation = None
      for permutation in itertools.permutations(range(r)):
          corr = 0
          for i, j in zip(range(r), permutation):
              corr += corr_matrix[i, j] / r
  
          if best_corr is None or corr > best_corr:
              best_corr = corr
              best_permutation = permutation
  
      return best_corr, best_permutation
  
file_path: tensorly/tensorly/metrics/tests/test_factors.py
imports: import itertools
  import pytest
  import tensorly
  from ..factors import congruence_coefficient
  from tensorly.random import random_cp
  from tensorly.cp_tensor import cp_permute_factors
label_desc: Use image node_id 2 for calling a global function with example usage: _congruence_coefficient_slow(A, B, absolute_value) and returns: best_corr,  best_permutation