docstr: Given prob over words for every last beam `wordLk` and attention
  `attnOut`: Compute and update the beam search.
  
  Parameters:
  
  * `wordLk`- probs of advancing from the last step (K x words)
  * `copy_indices` - copy indices (K x ctx_len)
  
  Returns: True if beam search is complete.
code: def advance(self, wordLk, copy_indices=None):
      """
      Given prob over words for every last beam `wordLk` and attention
      `attnOut`: Compute and update the beam search.
  
      Parameters:
  
      * `wordLk`- probs of advancing from the last step (K x words)
      * `copy_indices` - copy indices (K x ctx_len)
  
      Returns: True if beam search is complete.
      """
      if self.done:
          return True
      numWords = wordLk.size(1)
  
      # Sum the previous scores.
      if len(self.prevKs) > 0:
          beamLk = wordLk + self.scores.unsqueeze(1).expand_as(wordLk)
      else:
          # first step, expand from the first position
          beamLk = wordLk[0]
  
      flatBeamLk = beamLk.view(-1)
  
      bestScores, bestScoresId = flatBeamLk.topk(
          self.size, 0, True, True
      )
      self.allScores.append(self.scores)
      self.scores = bestScores
  
      # bestScoresId is flattened beam x word array, so calculate which
      # word and beam each score came from
      # bestScoreId is the integer ids, and numWords is the integer length.
      # Need to do integer division
      prevK = trunc_division(bestScoresId, numWords)
      self.prevKs.append(prevK)
      self.nextYs.append(bestScoresId - prevK * numWords)
      if copy_indices is not None:
          self.copy.append(copy_indices.index_select(0, prevK))
  
      # End condition is when top-of-beam is EOS.
      if self.nextYs[-1][0] == constant.EOS_ID:
          self.done = True
          self.allScores.append(self.scores)
  
      return self.done
  
file_path: stanza/stanza/models/common/beam.py
imports: from __future__ import division
  import torch
  import stanza.models.common.seq2seq_constant
label_desc: Use image node_id 4 for calling the Beam obj's underlying member method code with example usage: obj.advance(wordLk, copy_indices) and returns: self, True