code: def _scalar_type_std_res(self, counts, total, colsum, rowsum):
          
          expected_counts = expected_freq(counts)
          residuals = counts - expected_counts
          variance = (
              np.outer(rowsum, colsum)
              * np.outer(total - rowsum, total - colsum)
              / total ** 3
          )
          return residuals / np.sqrt(variance)
docs: Return ndarray containing standard residuals for category values.
  
          The shape of the return value is the same as that of *counts*.