Write a deterministic routine run_data_pipeline(vectors: list[list[int]], batch_size: int, pad_value: int, drop_last: bool) -> list[list[list[int]]] that processes an ordered list of integer vectors. The routine partitions the input into consecutive chunks, right-pads each retained chunk, and can drop a trailing chunk that is not full. Only run_data_pipeline is required as the entry point; internal helper organization is up to you.
Detailed behavior:
vectors in the given order. Do not shuffle or mutate the original vectors.batch_size, starting from index 0. Leftover vectors at the end form the final chunk.drop_last. If drop_last is true, remove that chunk completely; otherwise, retain it.L. Then right-append copies of pad_value to each shorter vector until that vector reaches length L.L.L is 0, so every vector remains empty and the chunk size is unchanged.Return the kept and padded chunks as a list of chunks, preserving their original relative order. Return an empty list if no chunks are kept.
Example 1:
Input: vectors = [[5,2,9],[8],[1,3,4,5]], batch_size = 2, pad_value = -1, drop_last = false
Output: [[[5,2,9],[8,-1,-1]], [[1,3,4,5]]]
Explanation: The first chunk has local maximum length 3, so [8] becomes [8,-1,-1]. The final single-vector chunk is incomplete but retained because drop_last is false.
vectors = [[5,2, 9], [8], [1, 3, 4, 5]] batch_size = 2 pad_value = -1 drop_last = false
[[[5,2, 9], [8, -1, -1]], [[1, 3, 4, 5]]]
Input: three vectors in order. batch_size=2, pad_value=-1, drop_last=false.
Example 2:
Input: vectors = [[], [7], [9,8,6], [2], [1,2]], batch_size = 2, pad_value = 4, drop_last = true
Output: [[[4],[7]], [[9,8,6],[2,4,4]]]
Explanation: In the first chunk the longest vector has length 1, so the empty vector becomes [4]. In the second chunk the longest vector has length 3, so [2] becomes [2,4,4]. The final chunk contains only one vector and is dropped.
Example 3:
Input: vectors = [[], [], []], batch_size = 3, pad_value = -2, drop_last = false
Output: [[[], [], []]]
Explanation: The only chunk is full and all vectors are empty, so no padding is inserted.
Constraints:
vectorsvectors and pad_value is an integer in drop_last is a boolean, and all input arguments are validvectors = [[5,2, 9], [8], [1, 3, 4, 5]] batch_size = 2 pad_value = -1 drop_last = false
[[[5,2, 9], [8, -1, -1]], [[1, 3, 4, 5]]]
Input: three vectors in order. batch_size=2, pad_value=-1, drop_last=false.