code: def index_trim_outlier(resid, k):
      """returns indices to residual array with k outliers removed
  
      Parameters
      ----------
      resid : array_like, 1d
          data vector, usually residuals of a regression
      k : int
          number of outliers to remove
  
      Returns
      -------
      trimmed_index : ndarray, 1d
          index array with k outliers removed
      outlier_index : ndarray, 1d
          index array of k outliers
  
      Notes
      -----
  
      Outliers are defined as the k observations with the largest
      absolute values.
  
      """
      sort_index = np.argsort(np.abs(resid))
      # index of non-outlier
      trimmed_index = np.sort(sort_index[:-k])
      outlier_index = np.sort(sort_index[-k:])
      return trimmed_index, outlier_index
  
imports: import numpy
  import statsmodels.api
  import matplotlib.pyplot
label_desc: Use image node_id 2 for calling a global function with example usage: index_trim_outlier(resid, k) and returns: trimmed_index,  outlier_index