code: def trim_dense(M, n_std=3, s_min=None, s_max=None):
      
  
      M = np.array(M)
      sparsity = M.sum(axis=1)
      mean = np.mean(sparsity)
      std = np.std(sparsity)
      if s_min is None:
          s_min = mean - n_std * std
      if s_max is None:
          s_max = mean + n_std * std
      elif s_max == 0:
          s_max = np.amax(M)
      f = (sparsity > s_min) * (sparsity < s_max)
      N = M[f][:, f]
      return N
docs: By default, return a matrix stripped of component
      vectors whose sparsity (i.e. total contact count on a
      single column or row) deviates more than specified number
      of standard deviations from the mean. Boolean variables
      s_min and s_max act as absolute fixed values which override
      such behaviour when specified.