Plotting the integer values in text format in matplotlib piechart
You got yourself in trouble by using plt.pie, and especially the keyword argument autopct, beyond its intended use. 

The basic idea of the pie chart is to have the wedge labels outside the pie and perhaps percentages inside.

You wanted the wedge label and percentage inside the pie and manipulated the autopct keyword with a function to achieve this. This involved cumbersome calculations from percentages to values you already know.

Another solution could be to use the more simple labels keyword argument and change the resulting texts properties to be inside the pie instead outside, see code changes below:

contents = ['23 users Cluster_0', '21 users Cluster_1']

data = [int(x.split()[0]) for x in contents]

def pie_chart_labels(data):
    total = int(np.sum(data))
    percentages = [100.0 * x / total for x in data]
    fmt_str = "{:.0f}%\n({:d} users)"
    return [fmt_str.format(p,i) for p,i in zip(percentages, data)]

wedges, texts,  = ax.pie(data, labels=pie_chart_labels(data))

# shrink label positions to be inside the pie
for t in texts:
    x,y = t.get_position()
    t.set_x(0.5 * x)
    t.set_y(0.5 * y)

plt.setp(texts, size=10, weight="bold", color="w", ha='center')