original_docstring: prune states that fall off the specified beam size
          
             Args:
                 j: current position (integer) in the sequence
                 delta: score matrix 
                 beam_size: specified size of the beam (integer)
          
docstring: prune states that fall off the specified beam size
docstring_tokens: prune states that fall off the specified beam size
code: def prune_states(self, j, delta, beam_size):
          """prune states that fall off the specified beam size
          
             Args:
                 j: current position (integer) in the sequence
                 delta: score matrix 
                 beam_size: specified size of the beam (integer)
          """
          P_codebook_rev = self.model.P_codebook_rev
          P_elems = self.model.P_elems
          #         pi_lendict = self.model.pi_lendict
  
          #         # sort the pi in descending order of their score
          #         indx_sorted_pi = numpy.argsort(delta[j,:])[::-1]
          #         # identify states falling out of the beam
          #         indx_falling_pi = indx_sorted_pi[beam_size:]
          #         # identify top-k states/pi
          #         indx_topk_pi = indx_sorted_pi[:beam_size]
          #         # remove the effect of states/pi falling out of the beam
          #         delta[j, indx_falling_pi] = -numpy.inf
  
          # using argpartition as better alternative to argsort
          indx_partitioned_pi = numpy.argpartition(-delta[j, :], beam_size)
          # identify top-k states/pi
          indx_topk_pi = indx_partitioned_pi[:beam_size]
          #         # identify states falling out of the beam
          #         indx_falling_pi = indx_partitioned_pi[beam_size:]
          #         # remove the effect of states/pi falling out of the beam
          #         delta[j, indx_falling_pi] = -numpy.inf
  
          # get topk states
          topk_pi = {P_codebook_rev[indx] for indx in indx_topk_pi}
          topk_states = set()
          for pi in topk_pi:
              topk_states.add(P_elems[pi][-1])
          return topk_states
code_tokens: def prune_states ( self , j , delta , beam_size ) : P_codebook_rev = self . model . P_codebook_rev P_elems = self . model . P_elems indx_partitioned_pi = numpy . argpartition ( - delta [ j , : ] , beam_size ) indx_topk_pi = indx_partitioned_pi [ : beam_size ] topk_pi = { P_codebook_rev [ indx ] for indx in indx_topk_pi } topk_states = set ( ) for pi in topk_pi : topk_states . add ( P_elems [ pi ] [ - 1 ] ) return topk_states
short_docstring: prune states that fall off the specified beam size
short_docstring_tokens: prune states that fall off the specified beam size
comment: """prune states that fall off the specified beam size
          
             Args:
                 j: current position (integer) in the sequence
                 delta: score matrix 
                 beam_size: specified size of the beam (integer)
          """$SEP$#         pi_lendict = self.model.pi_lendict$SEP$#         # sort the pi in descending order of their score$SEP$#         indx_sorted_pi = numpy.argsort(delta[j,:])[::-1]$SEP$#         # identify states falling out of the beam$SEP$#         indx_falling_pi = indx_sorted_pi[beam_size:]$SEP$#         # identify top-k states/pi$SEP$#         indx_topk_pi = indx_sorted_pi[:beam_size]$SEP$#         # remove the effect of states/pi falling out of the beam$SEP$#         delta[j, indx_falling_pi] = -numpy.inf$SEP$# using argpartition as better alternative to argsort$SEP$# identify top-k states/pi$SEP$#         # identify states falling out of the beam$SEP$#         indx_falling_pi = indx_partitioned_pi[beam_size:]$SEP$#         # remove the effect of states/pi falling out of the beam$SEP$#         delta[j, indx_falling_pi] = -numpy.inf$SEP$# get topk states