Show that $f$ is right invertible. Lete $f:A\to B$ be a surjective map. 

Show that $f$ is right invertible.

To prove this we need to construct a map $h:B\to A$ such that $f(h)=i_B$. Now as $f$ surjective so for each $b\in B$ there exist $a\in A$ such that $f(a)=b;$Let $A_b:=${$a\in A: f(a)=b$} Now choose any arbitrary element of $A_b$ for each $b$ in $B$. Now clearly it is the right inverse of $f$. But I want a verification that such a map from $B$ to $A$ is well defined.
 A: You are right that you want to verify that this is a well-defined function. Let $a_b\in A_b$ the chosen element. Then we want to check that $g=\{\langle b,a_b\rangle\mid b\in B\}$ is an injective function from $B$ into $A$.
To see that it is a function, note that if $\langle b,x\rangle$ and $\langle b,y\rangle$ are both in $g$, then by the definition of $g$, $x=a_b$ and $y=a_b$. While our choice was arbitrary, we only chose one element from each $A_b$. Therefore $x=y$ and so $g$ is indeed a function.
The rest, as you note, is quite simple.
It should be noted that (1) the axiom of choice is definitely needed for making these arbitrary choices; (2) depending on how you formulate the axiom of choice, $g$ may just be taken as a choice function for the family $\{A_b\mid b\in B\}$, which you have shown to be a family of non-empty sets; and (3) in either way, this follows from the fact that the axiom of choice (in any of its infinitely many formulations) gives arbitrary choices, but well-defined choices.
