text.pad_along_dimension

Add padding to the beginning and end of data in a specific dimension.

Returns a tensor constructed from data, where each row in dimension axis is replaced by the concatenation of the left padding followed by the row followed by the right padding. I.e., if L=left_pad.shape[0] and R=right_pad.shape[0], then:

result[i1...iaxis, 0:L] = left_pad
result[i1...iaxis, L:-R] = data[i0...iaxis]
result[i1...iaxis, -R:] = right_pad

data <dtype>[O1...ON, A, I1...IM] A potentially ragged K dimensional tensor with outer dimensions of size O1...ON; axis dimension of size A; and inner dimensions of size I1...IM. I.e. K = N + 1 + M, where N>=0 and M>=0.
axis An integer constant specifying the axis along which padding is added. Negative axis values from -K to -1 are supported.
left_pad <dtype>[L, I1...IM] An M+1 dimensional tensor that should be prepended to each row along dimension axis; or None if no padding should be added to the left side.
right_pad <dtype>[R, I1...IM] An M+1 dimensional tensor that should be appended to each row along dimension axis; or None if no padding should be added to the right side.
name The name of this op (optional).

<dtype>[O1...ON, L + A + R, I1...IM] A potentially ragged K dimensional tensor with outer dimensions of size O1...ON; padded axis dimension size L+A+R; and inner dimensions of size I1...IM. If data is a RaggedTensor, then the returned tensor is a RaggedTensor with the same ragged_rank.