docs: def calc_individual_chi_squares(residuals,
                                  long_probabilities,
                                  rows_to_obs):
      """
      Calculates individual chi-squared values for each choice situation in the
      dataset.
  
      Parameters
      ----------
      residuals : 1D ndarray.
          The choice vector minus the predicted probability of each alternative
          for each observation.
      long_probabilities : 1D ndarray.
          The probability of each alternative being chosen in each choice
          situation.
      rows_to_obs : 2D scipy sparse array.
          Should map each row of the long format dataferame to the unique
          observations in the dataset.
  
      Returns
      -------
      ind_chi_squareds : 1D ndarray.
          Will have as many elements as there are columns in `rows_to_obs`. Each
          element will contain the pearson chi-squared value for the given choice
          situation.
      """
      chi_squared_terms = np.square(residuals) / long_probabilities
      return rows_to_obs.T.dot(chi_squared_terms)