class_docstr: Abstract base class for all beam scorers that are used for :meth:`~transformers.PreTrainedModel.beam_search` and
  :meth:`~transformers.PreTrainedModel.beam_sample`.
class_docstr_tok: ["Abstract","base","class","for","all","beam","scorers","that","are","used","for",":","meth",":","`","~transformers.PreTrainedModel.beam_search","`","and",":","meth",":","`","~transformers.PreTrainedModel.beam_sample","`","."]
code: def finalize(
      self,
      input_ids: "torch.LongTensor",
      next_scores: "torch.FloatTensor",
      next_tokens: "torch.LongTensor",
      next_indices: "torch.LongTensor",
      max_length: int,
      **kwargs,
  ) -> "torch.LongTensor":
      raise NotImplementedError("This is an abstract method.")
  
imports: from abc import ABC, abstractmethod
  from collections import UserDict
  from typing import Optional, Tuple
  from .file_utils import add_start_docstrings
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
  from fastNLP.core.log import logger
label_desc: Use image node_id 2 for calling the BeamScorer obj's underlying member method code with example usage: obj.finalize(input_ids, next_scores, next_tokens, next_indices, max_length) without return types