class_docstr: This is a utility class that combines a model, a masker object, and a current input.
  
  The combination of a model, a masker object, and a current input produces a binary set
  function that can be called to mask out any set of inputs. This class attempts to be smart
  about only evaluating the model for background samples when the inputs changed (note this
  requires the masker object to have a .invariants method).
class_docstr_tok: ["This","is","a","utility","class","that","combines","a","model",",","a","masker","object",",","and","a","current","input",".","The","combination","of","a","model",",","a","masker","object",",","and","a","current","input","produces","a","binary","set","function","that","can","be","called","to","mask","out","any","set","of","inputs",".","This","class","attempts","to","be","smart","about","only","evaluating","the","model","for","background","samples","when","the","inputs","changed","(","note","this","requires","the","masker","object","to","have","a",".invariants","method",")","."]
docstr: Compute the main effects for this model.
          
docstr_tok: ["Compute","the","main","effects","for","this","model","."]
code: def main_effects(self, inds=None, batch_size=None):
      """Compute the main effects for this model."""
  
      # if no indexes are given then we assume all indexes could be non-zero
      if inds is None:
          inds = np.arange(len(self))
  
      # mask each potentially nonzero input in isolation
      masks = np.zeros(2 * len(inds), dtype=int)
      masks[0] = MaskedModel.delta_mask_noop_value
      last_ind = -1
      for i in range(len(inds)):
          if i > 0:
              masks[2 * i] = -last_ind - 1  # turn off the last input
          masks[2 * i + 1] = inds[i]  # turn on this input
          last_ind = inds[i]
  
      # compute the main effects for the given indexes
      outputs = self(masks, batch_size=batch_size)
      main_effects = outputs[1:] - outputs[0]
  
      # expand the vector to the full input size
      expanded_main_effects = np.zeros((len(self),) + outputs.shape[1:])
      for i, ind in enumerate(inds):
          expanded_main_effects[ind] = main_effects[i]
  
      return expanded_main_effects
  
imports: import copy
  import numpy
  import scipy.sparse
  from numba import njit
  from ..None import links
label_desc: Use image node_id 8 for calling the MaskedModel obj's underlying member method code with example usage: obj.main_effects(inds, batch_size) and returns: expanded_main_effects