original_docstring: 
      Function to evaluate the Discounted Cumulative Gain @ k for a given
      ground truth vector and a list of predictions (between 0 and 1).
  
      Args:
          ground_truth : np.array consisting of multi-hot encoding of label
                         vector
          predictions : np.array consisting of predictive probabilities for
                        every label.
          k : Value of k. Default: 5
          pos_label : Value to consider as positive. Default: 1
  
      Returns:
          DCG @ k for a given ground truth - prediction pair.
      
docstring: Function to evaluate the Discounted Cumulative Gain @ k for a given
  ground truth vector and a list of predictions (between 0 and 1).
docstring_tokens: Function to evaluate the Discounted Cumulative Gain @ k for a given ground truth vector and a list of predictions ( between 0 and 1 ) .
code: def dcg_score_at_k(ground_truth, predictions, k=5, pos_label=1, device='cpu'):
      """
      Function to evaluate the Discounted Cumulative Gain @ k for a given
      ground truth vector and a list of predictions (between 0 and 1).
  
      Args:
          ground_truth : np.array consisting of multi-hot encoding of label
                         vector
          predictions : np.array consisting of predictive probabilities for
                        every label.
          k : Value of k. Default: 5
          pos_label : Value to consider as positive. Default: 1
  
      Returns:
          DCG @ k for a given ground truth - prediction pair.
      """
      #assert ground_truth.size() == predictions.size(), "P@k: Length mismatch"
  
      if ground_truth.size() == predictions.size():
          desc_order = torch.argsort(predictions, dim=1, descending=True) # ::-1 reverses array
      else:
          desc_order = predictions
      ground_truth = torch.gather(ground_truth, 1, desc_order[:, :k])  # the top indices
      gains = torch.pow(2.0, ground_truth) - 1
  
      discounts = torch.log2(torch.arange(1, ground_truth.size(1) + 1) + 1.0)
      return torch.sum(torch.div(gains, discounts.to(device=device)), dim=1)
code_tokens: def dcg_score_at_k ( ground_truth , predictions , k = 5 , pos_label = 1 , device = 'cpu' ) : if ground_truth . size ( ) == predictions . size ( ) : desc_order = torch . argsort ( predictions , dim = 1 , descending = True ) else : desc_order = predictions ground_truth = torch . gather ( ground_truth , 1 , desc_order [ : , : k ] ) gains = torch . pow ( 2.0 , ground_truth ) - 1 discounts = torch . log2 ( torch . arange ( 1 , ground_truth . size ( 1 ) + 1 ) + 1.0 ) return torch . sum ( torch . div ( gains , discounts . to ( device = device ) ) , dim = 1 )
short_docstring: Function to evaluate the Discounted Cumulative Gain @ k for a given
  ground truth vector and a list of predictions (between 0 and 1).
short_docstring_tokens: Function to evaluate the Discounted Cumulative Gain @ k for a given ground truth vector and a list of predictions ( between 0 and 1 ) .
comment: """
      Function to evaluate the Discounted Cumulative Gain @ k for a given
      ground truth vector and a list of predictions (between 0 and 1).
  
      Args:
          ground_truth : np.array consisting of multi-hot encoding of label
                         vector
          predictions : np.array consisting of predictive probabilities for
                        every label.
          k : Value of k. Default: 5
          pos_label : Value to consider as positive. Default: 1
  
      Returns:
          DCG @ k for a given ground truth - prediction pair.
      """$SEP$#assert ground_truth.size() == predictions.size(), "P@k: Length mismatch"$SEP$# ::-1 reverses array$SEP$# the top indices