def split_embedding_weight(self, weight, vocab_size, count, pad_num=0):
    split = []  # [tensor, clip_min, clip_max, offset]
    assert vocab_size % count == 0
    num_valid_token = vocab_size // count

    weight_list = np.split(weight, count, 0)
    pad = np.zeros((1, weight.shape[1]), dtype=weight.dtype)
    for i in range(count):
        weight_ = weight_list[i]
        # Each partial embedding has 2 pad tokens.
        weight_ = np.concatenate([pad, weight_], axis=0)
        weight_ = np.concatenate([weight_, pad], axis=0)

        clip_min = i * num_valid_token - 1
        clip_max = (i+1) * num_valid_token
        offset = clip_min
        split.append([weight_, clip_min, clip_max, offset])

    pad_mask = np.zeros((1, weight_.shape[0]), dtype=weight_.dtype)
    if pad_num > 0:
        pad_mask[:, -(pad_num+1):] = -1000.0
    return split, pad_mask Write your response with exactly 7 paragraphs, separated with the markdown divider: ***.
user