code: def get_beam_ranking_function(
      ranking_algorithm: BeamRankingAlgorithm,
  ):
      if (
          ranking_algorithm
          == BeamRankingAlgorithm.LENGTH_CONDITIONED_RANK
      ):
          return length_conditioned_rank
      elif (
          ranking_algorithm
          == BeamRankingAlgorithm.LENGTH_CONDITIONED_RANK_MUL
      ):
          return length_conditioned_rank_mul
      elif (
          ranking_algorithm == BeamRankingAlgorithm.AVERAGE_TOKEN_LPROB
      ):
          return avg_token_lprob
      elif (
          ranking_algorithm
          == BeamRankingAlgorithm.LENGTH_CONDITIONED_AVERAGE_TOKEN_LPROB
      ):
          return length_conditioned_avg_lprob_rank
      elif (
          ranking_algorithm
          == BeamRankingAlgorithm.LENGTH_CONDITIONED_AVERAGE_TOKEN_LPROB_MULTIPLIED
      ):
          return length_conditioned_avg_lprob_rank_mul
      elif ranking_algorithm == BeamRankingAlgorithm.TOKEN_LPROB:
          return token_prob
      elif ranking_algorithm == BeamRankingAlgorithm.LEN_ONLY:
          return length
      else:
          raise Exception(
              f"Unknown ranking algorithm {ranking_algorithm}"
          )
  
imports: from enum import Enum
  from typing import Dict, Optional, Tuple
  import torch
  from pytext.common.constants import TORCH_VERSION
  from pytext.config import ConfigBase
  from pytext.models.module import Module
  from pytext.torchscript.vocab import ScriptVocabulary
  from torch import Tensor
label_desc: Use image node_id 8 for calling a global function with example usage: get_beam_ranking_function(ranking_algorithm) and returns: length_conditioned_rank, length_conditioned_rank_mul, avg_token_lprob, length_conditioned_avg_lprob_rank, length_conditioned_avg_lprob_rank_mul, token_prob, length