code: def gray_code_indexes(nbits):
      """Produces an array of which bits flip at which position.
  
      We assume the masks start at all zero and -1 means don't do a flip.
      This is a more efficient representation of the gray_code_masks version.
      """
      out = (
          np.ones(2**nbits, dtype=int)
          * MaskedModel.delta_mask_noop_value
      )
      li = np.zeros(nbits, dtype=bool)
      for term in range((1 << nbits) - 1):
          if term % 2 == 1:  # odd
              for i in range(-1, -nbits, -1):
                  if li[i] == 1:
                      li[i - 1] = li[i - 1] ^ 1
                      out[term + 1] = nbits + (i - 1)
                      break
          else:  # even
              li[-1] = li[-1] ^ 1
              out[term + 1] = nbits - 1
      return out
  
file_path: shap/shap/explainers/_exact.py
imports: import logging
  import numpy
  from numba import njit
  from ..None import links
  from ..models import Model
  from ..utils import MaskedModel, delta_minimization_order, make_masks, shapley_coefficients
  from ._explainer import Explainer
label_desc: Use image node_id 7 for calling a global function with example usage: gray_code_indexes(nbits) and returns: out