code: def test_feature_names_slicing_for_square_arrays(random_seed, N):
      """Checks that feature names in Explanations are properly sliced with "square"
      arrays (N==k).
  
      For 2D arrays, there is an ambiguity in how to assign the feature names to the
      slicer index. E.g. if feature_names is a list of 5 elements, and the shap_values is
      a (5,5) array, it's ambiguous whether the axis=0 or axis=1 refers to the "feature
      columns".
  
      This test ensures that we give higher priority to axis=1 for the feature_names for
      square arrays. Since most of the time, the 2D shap values arrays are assembled as
      (# samples, # features).
  
      cf. GH #2722, GH #2699.
      """
      rs = np.random.RandomState(random_seed)
      featnames = list("abcde")
  
      exp = shap.Explanation(
          # an array of this shape typically arises as the shap values of N samples, k=5 features
          values=rs.rand(N, 5),
          feature_names=featnames,
          output_names=featnames,
      )
      first_sample = exp[0]
      # exp[0] used to return "a" incorrectly when N=5 here, instead of ["a","b","c","d","e"]
      assert (
          first_sample.feature_names
          == first_sample.output_names
          == featnames
      )
      column_e = exp[..., "e"]
      assert column_e.feature_names == "e"
  
imports: import numpy
  import pytest
  import shap
label_desc: Use image node_id 3 for calling a global function with example usage: test_feature_names_slicing_for_square_arrays(random_seed, N) without return types