nodes: 0, module; 1, function_definition; 2, function_name:footrule_dist; 3, parameters; 4, block; 5, identifier:params1; 6, default_parameter; 7, expression_statement; 8, assert_statement; 9, expression_statement; 10, if_statement; 11, return_statement; 12, identifier:params2; 13, None; 14, comment:r"""Compute Spearman's footrule distance between two models.
  
      This function computes Spearman's footrule distance between the rankings
      induced by two parameter vectors. Let :math:`\sigma_i` be the rank of item
      ``i`` in the model described by ``params1``, and :math:`\tau_i` be its rank
      in the model described by ``params2``. Spearman's footrule distance is
      defined by
  
      .. math::
  
        \sum_{i=1}^N | \sigma_i - \tau_i |
  
      By convention, items with the lowest parameters are ranked first (i.e.,
      sorted using the natural order).
  
      If the argument ``params2`` is ``None``, the second model is assumed to
      rank the items by their index: item ``0`` has rank 1, item ``1`` has rank
      2, etc.
  
      Parameters
      ----------
      params1 : array_like
          Parameters of the first model.
      params2 : array_like, optional
          Parameters of the second model.
  
      Returns
      -------
      dist : float
          Spearman's footrule distance.
      """; 15, boolean_operator; 16, assignment; 17, comparison_operator:params2 is None; 18, block; 19, else_clause; 20, call; 21, comparison_operator:params2 is None; 22, comparison_operator:len(params1) == len(params2); 23, identifier:ranks1; 24, call; 25, identifier:params2; 26, None; 27, expression_statement; 28, block; 29, attribute; 30, argument_list; 31, identifier:params2; 32, None; 33, call; 34, call; 35, identifier:rankdata; 36, argument_list; 37, assignment; 38, expression_statement; 39, identifier:np; 40, identifier:sum; 41, call; 42, identifier:len; 43, argument_list; 44, identifier:len; 45, argument_list; 46, identifier:params1; 47, keyword_argument; 48, identifier:ranks2; 49, call; 50, assignment; 51, attribute; 52, argument_list; 53, identifier:params1; 54, identifier:params2; 55, identifier:method; 56, string:"average"; 57, attribute; 58, argument_list; 59, identifier:ranks2; 60, call; 61, identifier:np; 62, identifier:abs; 63, binary_operator:ranks1 - ranks2; 64, identifier:np; 65, identifier:arange; 66, integer:1; 67, binary_operator:len(params1) + 1; 68, keyword_argument; 69, identifier:rankdata; 70, argument_list; 71, identifier:ranks1; 72, identifier:ranks2; 73, call; 74, integer:1; 75, identifier:dtype; 76, identifier:float; 77, identifier:params2; 78, keyword_argument; 79, identifier:len; 80, argument_list; 81, identifier:method; 82, string:"average"; 83, identifier:params1
code: def footrule_dist(params1, params2=None):
      r"""Compute Spearman's footrule distance between two models.
  
      This function computes Spearman's footrule distance between the rankings
      induced by two parameter vectors. Let :math:`\sigma_i` be the rank of item
      ``i`` in the model described by ``params1``, and :math:`\tau_i` be its rank
      in the model described by ``params2``. Spearman's footrule distance is
      defined by
  
      .. math::
  
        \sum_{i=1}^N | \sigma_i - \tau_i |
  
      By convention, items with the lowest parameters are ranked first (i.e.,
      sorted using the natural order).
  
      If the argument ``params2`` is ``None``, the second model is assumed to
      rank the items by their index: item ``0`` has rank 1, item ``1`` has rank
      2, etc.
  
      Parameters
      ----------
      params1 : array_like
          Parameters of the first model.
      params2 : array_like, optional
          Parameters of the second model.
  
      Returns
      -------
      dist : float
          Spearman's footrule distance.
      """
      assert params2 is None or len(params1) == len(params2)
      ranks1 = rankdata(params1, method="average")
      if params2 is None:
          ranks2 = np.arange(1, len(params1) + 1, dtype=float)
      else:
          ranks2 = rankdata(params2, method="average")
      return np.sum(np.abs(ranks1 - ranks2))