docstr: Finalize search and return the final candidate sequences
  
  Parameters
  ----------
  tokens : Tensor, shape = (n_audio, n_group, current_sequence_length)
      all tokens in the context so far, including the prefix and sot_sequence
  
  sum_logprobs : Tensor, shape = (n_audio, n_group)
      cumulative log probabilities for each sequence
  
  Returns
  -------
  tokens : Sequence[Sequence[Tensor]], length = n_audio
      sequence of Tensors containing candidate token sequences, for each audio input
  
  sum_logprobs : List[List[float]], length = n_audio
      sequence of cumulative log probabilities corresponding to the above
docstr_tok: ["Finalize","search","and","return","the","final","candidate","sequences","Parameters","--","--","--","--","--","tokens",":","Tensor",",","shape","=","(","n_audio",",","n_group",",","current_sequence_length",")","all","tokens","in","the","context","so","far",",","including","the","prefix","and","sot_sequence","sum_logprobs",":","Tensor",",","shape","=","(","n_audio",",","n_group",")","cumulative","log","probabilities","for","each","sequence","Returns","--","--","--","-","tokens",":","Sequence","[","Sequence","[","Tensor","]","]",",","length","=","n_audio","sequence","of","Tensors","containing","candidate","token","sequences",",","for","each","audio","input","sum_logprobs",":","List","[","List","[","float","]","]",",","length","=","n_audio","sequence","of","cumulative","log","probabilities","corresponding","to","the","above"]
code: def finalize(
      self, tokens: Tensor, sum_logprobs: Tensor
  ) -> Tuple[Sequence[Sequence[Tensor]], List[List[float]]]:
      """Finalize search and return the final candidate sequences
  
      Parameters
      ----------
      tokens : Tensor, shape = (n_audio, n_group, current_sequence_length)
          all tokens in the context so far, including the prefix and sot_sequence
  
      sum_logprobs : Tensor, shape = (n_audio, n_group)
          cumulative log probabilities for each sequence
  
      Returns
      -------
      tokens : Sequence[Sequence[Tensor]], length = n_audio
          sequence of Tensors containing candidate token sequences, for each audio input
  
      sum_logprobs : List[List[float]], length = n_audio
          sequence of cumulative log probabilities corresponding to the above
  
      """
      raise NotImplementedError
  
imports: from dataclasses import dataclass, field, replace
  from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  import torch.nn.functional
  from torch import Tensor
  from torch.distributions import Categorical
  from .audio import CHUNK_LENGTH
  from .tokenizer import Tokenizer, get_tokenizer
  from .utils import compression_ratio
label_desc: Use image node_id 3 for calling the TokenDecoder obj's underlying member method code with example usage: obj.finalize(tokens, sum_logprobs) without return types