code: def contrast_allpairs(nm):
      """contrast or restriction matrix for all pairs of nm variables
  
      Parameters
      ----------
      nm : int
  
      Returns
      -------
      contr : ndarray, 2d, (nm*(nm-1)/2, nm)
         contrast matrix for all pairwise comparisons
  
      """
      contr = []
      for i in range(nm):
          for j in range(i + 1, nm):
              contr_row = np.zeros(nm)
              contr_row[i] = 1
              contr_row[j] = -1
              contr.append(contr_row)
      return np.array(contr)
  
imports: from collections import namedtuple
  from statsmodels.compat.python import lzip, lrange
  import copy
  import math
  import numpy
  from numpy.testing import assert_almost_equal, assert_equal
  from scipy import stats, interpolate
  from statsmodels.iolib.table import SimpleTable
  from statsmodels.stats.multitest import multipletests, _ecdf, fdrcorrection, fdrcorrection_twostage
  from statsmodels.graphics import utils
  from statsmodels.tools.sm_exceptions import ValueWarning
label_desc: Use image node_id 23 for calling a global function with example usage: contrast_allpairs(nm) and returns: np