def _pack_on_flat(tensor: "NDArray") -> "NDArray":
        """Pack two uint4 into one uint8 on a flattened tensor."""
        tensor = tensor.flatten()

        if len(tensor) % 2:
            tensor = np.pad(tensor, (0, 1), mode="constant")

        # right 4 bits are the first uint4
        return (tensor[0::2] & 0xF) | ((tensor[1::2] & 0xF) << 4)
Pack two uint4 into one uint8 on a flattened tensor.
olive/passes/onnx/mnb_to_qdq.py