class_docstr: The collector is used to collect the resource for evaluator.
  As the evaluation metrics are various, the needed resource not only contain the recommended result
  but also other resource from data and model. They all can be collected by the collector during the training
  and evaluation process.
  
  This class is only used in Trainer.
docstr: Get the ranking of an ordered tensor, and take the average of the ranking for positions with equal values.
  
  Args:
      scores(tensor): an ordered tensor, with size of `(N, )`
  
  Returns:
      torch.Tensor: average_rank
  
  Example:
      >>> average_rank(tensor([[1,2,2,2,3,3,6],[2,2,2,2,4,5,5]]))
      tensor([[1.0000, 3.0000, 3.0000, 3.0000, 5.5000, 5.5000, 7.0000],
      [2.5000, 2.5000, 2.5000, 2.5000, 5.0000, 6.5000, 6.5000]])
  
  Reference:
      https://github.com/scipy/scipy/blob/v0.17.1/scipy/stats/stats.py#L5262-L5352
docstr_tok: ["Get","the","ranking","of","an","ordered","tensor",",","and","take","the","average","of","the","ranking","for","positions","with","equal","values",".","Args",":","scores","(","tensor",")",":","an","ordered","tensor",",","with","size","of","`","(","N",",",")","`","Returns",":","torch.Tensor",":","average_rank","Example",":",">",">",">","average_rank","(","tensor","(","[","[","1,2,2,2,3,3,6","]",",","[","2,2,2,2,4,5,5","]","]",")",")","tensor","(","[","[","1.0000",",","3.0000",",","3.0000",",","3.0000",",","5.5000",",","5.5000",",","7.0000","]",",","[","2.5000",",","2.5000",",","2.5000",",","2.5000",",","5.0000",",","6.5000",",","6.5000","]","]",")","Reference",":","https",":","\/\/github.com\/scipy\/scipy\/blob\/v0.17.1\/scipy\/stats\/stats.py","#","L5262-L5352"]
code: def _average_rank(self, scores):
      """Get the ranking of an ordered tensor, and take the average of the ranking for positions with equal values.
  
      Args:
          scores(tensor): an ordered tensor, with size of `(N, )`
  
      Returns:
          torch.Tensor: average_rank
  
      Example:
          >>> average_rank(tensor([[1,2,2,2,3,3,6],[2,2,2,2,4,5,5]]))
          tensor([[1.0000, 3.0000, 3.0000, 3.0000, 5.5000, 5.5000, 7.0000],
          [2.5000, 2.5000, 2.5000, 2.5000, 5.0000, 6.5000, 6.5000]])
  
      Reference:
          https://github.com/scipy/scipy/blob/v0.17.1/scipy/stats/stats.py#L5262-L5352
  
      """
      length, width = scores.shape
      true_tensor = torch.full(
          (length, 1), True, dtype=torch.bool, device=self.device
      )
  
      obs = torch.cat(
          [true_tensor, scores[:, 1:] != scores[:, :-1]], dim=1
      )
      # bias added to dense
      bias = (
          torch.arange(0, length, device=self.device)
          .repeat(width)
          .reshape(width, -1)
          .transpose(1, 0)
          .reshape(-1)
      )
      dense = obs.view(-1).cumsum(0) + bias
  
      # cumulative counts of each unique value
      count = torch.where(torch.cat([obs, true_tensor], dim=1))[1]
      # get average rank
      avg_rank = 0.5 * (count[dense] + count[dense - 1] + 1).view(
          length, -1
      )
  
      return avg_rank
  
imports: from recbole.evaluator.register import Register
  import torch
  import copy
label_desc: Use image node_id 3 for calling the Collector obj's underlying member method code with example usage: obj._average_rank(scores) and returns: avg_rank