class_docstr: Top K Categorical accuracy metric. Uses torch.topk to determine the top k predictions and compares to targets.
  Decorated with a mean, running_mean and std. Default for keys: 'top_5_acc', 'top_10_acc'.
  
  Args:
      pred_key (StateKey): The key in state which holds the predicted values
      target_key (StateKey): The key in state which holds the target values
      ignore_index (int): Specifies a target value that is ignored and does not contribute to the metric output.
          See `<https://pytorch.org/docs/stable/nn.html#crossentropyloss>`_
class_docstr_tok: ["Top","K","Categorical","accuracy","metric",".","Uses","torch.topk","to","determine","the","top","k","predictions","and","compares","to","targets",".","Decorated","with","a","mean",",","running_mean","and","std",".","Default","for","keys",":","'top_5_acc","'",",","'top_10_acc","'",".","Args",":","pred_key","(","StateKey",")",":","The","key","in","state","which","holds","the","predicted","values","target_key","(","StateKey",")",":","The","key","in","state","which","holds","the","target","values","ignore_index","(","int",")",":","Specifies","a","target","value","that","is","ignored","and","does","not","contribute","to","the","metric","output",".","See","`","<","https",":","\/\/pytorch.org\/docs\/stable\/nn.html","#","crossentropyloss",">","`","_"]
code: def process(self, *args):
      state = args[0]
      y_pred = state[self.pred_key]
      y_true = state[self.target_key]
      mask = y_true.eq(self.ignore_index).eq(0)
      y_pred = y_pred[mask]
      y_true = y_true[mask]
  
      sorted_indices = torch.topk(y_pred, self.k, dim=1)[1]
      expanded_y = y_true.view(-1, 1).expand(-1, self.k)
      return torch.sum(
          torch.eq(sorted_indices, expanded_y), dim=1
      ).float()
  
imports: import torchbearer
  from torchbearer import Metric
  from .decorators import default_for_key, running_mean, mean, std, to_dict
  import torch
label_desc: Use image node_id 2 for calling the TopKCategoricalAccuracy obj's underlying member method code with example usage: obj.process() and returns: torch