code: def _concat_translations(
      translations: List[Translation],
      stop_ids: Set[int],
      scorer: CandidateScorer,
  ) -> Translation:
      """
      Combines translations through concatenation.
  
      :param translations: A list of translations (sequence starting with BOS symbol), score and length.
      :param stop_ids: The EOS symbols.
      :param scorer: Candidate scorer for recomputing score of concatenated translations.
      :return: A concatenation of the translations with a score.
      """
      if len(translations) == 1:
          return translations[0]
  
      # Concatenation of all target ids without BOS and EOS
      target_ids = []
      estimated_reference_length = None  # type: Optional[float]
      scores = np.zeros_like(translations[0].scores)  # type: np.ndarray
  
      for idx, translation in enumerate(translations):
          if idx == len(translations) - 1:
              target_ids.extend(translation.target_ids)
          else:
              if translation.target_ids[-1][0] in stop_ids:
                  target_ids.extend(translation.target_ids[:-1])
              else:
                  target_ids.extend(translation.target_ids)
          if translation.estimated_reference_length is not None:
              if estimated_reference_length is None:
                  estimated_reference_length = (
                      translation.estimated_reference_length
                  )
              else:
                  estimated_reference_length += (
                      translation.estimated_reference_length
                  )
  
          score, *factor_scores = translation.scores
          # Unnormalize the primary score:
          raw_score = scorer.unnormalize(
              score,
              len(translation.target_ids),
              translation.estimated_reference_length,
          )
          # Accumulate scores element-wise
          scores = np.add(scores, [raw_score, *factor_scores])
  
      # Re-normalize the primary score
      scores[0] = scorer(
          scores[0], len(target_ids), estimated_reference_length
      )
  
      return Translation(
          target_ids,
          scores.tolist(),
          estimated_reference_length=estimated_reference_length,
      )
  
imports: import copy
  import itertools
  import json
  import logging
  from dataclasses import dataclass
  from functools import partial
  from typing import Any, Callable, Dict, Generator, List, Optional, Set, Tuple, Union
  import numpy
  import torch
  from .None import constants
  from .None import lexicon
  from .None import utils
  from .None import vocab
  from .beam_search import CandidateScorer, get_search_algorithm, GreedySearch, SearchResult
  from .data_io import tokens2ids, get_prepended_token_length
  from .model import SockeyeModel
label_desc: Use image node_id 14 for calling a global function with example usage: _concat_translations(translations, stop_ids, scorer) and returns: Translation, translations