WordPress get_avatar function not correct working

You pull the author ID here:

$autid= get_userdata($author)->ID;

So why aren’t you using it to get the avatar on the very next line?

echo get_avatar( get_the_author_email(), '32' );

get_avatar will accept the ID as a parameter. Try this instead:

echo get_avatar( $autid, '32' );

get_the-author_email is deprecated anyway so even if it worked you shouldn’t be using it.