from typing import List
from typing import Tuple
from typing import Optional


def get_additional_data_lengths(source_pre: List[List[str]],
                                source_nxt: List[List[str]],
                                target_pre: List[List[str]],
                                target_nxt: List[List[str]]) -> Tuple[Optional[List[int]],
                                                                      Optional[List[int]],
                                                                      Optional[List[int]],
                                                                      Optional[List[int]]]:
    """
    Computes lengths of additional data.

    :param source_pre: List of previous source sentences as strings.
    :param source_nxt: List of next source sentences as strings.
    :param target_pre: List of previous target sentences as strings.
    :param target_nxt: List of next target sentences as strings.
    :return: Respective lengths of additional input strings.
    """
    source_pre_lens = [len(src_pre) for src_pre in source_pre] if source_pre else None
    source_nxt_lens = [len(src_nxt) for src_nxt in source_nxt] if source_nxt else None
    target_pre_lens = [len(tar_pre) for tar_pre in target_pre] if target_pre else None
    target_nxt_lens = [len(tar_nxt) for tar_nxt in target_nxt] if target_nxt else None
    return source_pre_lens, source_nxt_lens, target_pre_lens, target_nxt_lens