code: def cov_multinomial(probs):
      """covariance matrix of multinomial distribution
  
      This is vectorized with choices along last axis.
  
      cov = diag(probs) - outer(probs, probs)
  
      """
  
      k = probs.shape[-1]
      di = np.diag_indices(k, 2)
      cov = probs[..., None] * probs[..., None, :]
      cov *= -1
      cov[..., di[0], di[1]] += probs
      return cov
  
file_path: statsmodels/statsmodels/stats/diagnostic_gen.py
imports: import numpy
  from scipy import stats
  from statsmodels.stats.base import HolderTuple
  from statsmodels.stats.effect_size import _noncentrality_chisquare
label_desc: Use image node_id 4 for calling a global function with example usage: cov_multinomial(probs) and returns: cov