parameters: (self, correct, *args)
return_statement: return accs
docstring: Update the metrics states (correct count and total count), in order to
          calculate cumulative accuracy of all instances. This function also
          returns the accuracy of current step.
          
          Args:
              correct: Correct mask, a tensor with shape [batch_size, d0, ..., topk].
  
          Return:
              Tensor: the accuracy of current step.
docstring_summary: Update the metrics states (correct count and total count), in order to
          calculate cumulative accuracy of all instances. This function also
          returns the accuracy of current step.
          
          Args:
              correct: Correct mask, a tensor with shape [batch_size, d0, ..., topk].
docstring_tokens: Update the metrics states ( correct count and total count ) in order to calculate cumulative accuracy of all instances . This function also returns the accuracy of current step . Args : correct : Correct mask a tensor with shape [ batch_size d0 ... topk ] .
function: def update(self, correct, *args):
          """
          Update the metrics states (correct count and total count), in order to
          calculate cumulative accuracy of all instances. This function also
          returns the accuracy of current step.
          
          Args:
              correct: Correct mask, a tensor with shape [batch_size, d0, ..., topk].
  
          Return:
              Tensor: the accuracy of current step.
          """
          if isinstance(correct, paddle.Tensor):
              correct = correct.numpy()
          num_samples = np.prod(np.array(correct.shape[:-1]))
          accs = []
          for i, k in enumerate(self.topk):
              num_corrects = correct[..., :k].sum()
              accs.append(float(num_corrects) / num_samples)
              self.total[i] += num_corrects
              self.count[i] += num_samples
          accs = accs[0] if len(self.topk) == 1 else accs
          return accs
function_tokens: def update ( self , correct , * args ) : if isinstance ( correct , paddle . Tensor ) : correct = correct . numpy ( ) num_samples = np . prod ( np . array ( correct . shape [ : - 1 ] ) ) accs = [ ] for i , k in enumerate ( self . topk ) : num_corrects = correct [ ... , : k ] . sum ( ) accs . append ( float ( num_corrects ) / num_samples ) self . total [ i ] += num_corrects self . count [ i ] += num_samples accs = accs [ 0 ] if len ( self . topk ) == 1 else accs return accs