"In any way" is the key portion of that phrase, because "stupid" just means a lack of intelligence or understanding. The term "in any way" means to not participate at all, even if there is more than one way to do so. "Stupid" could even come before "in any way" in the sentence and still be correct. It could also be replaced easily with other words.
For an example, let's say a teenager is assigned to lead a high school fundraiser. If they ask a friend if they would like to help out and the friend says, "Not in any way", the friend is declining to help with anything related to the fundraiser. It could be mental help (thinking of ideas), physical help (setting up or cleaning up), practical help (organizing team members, making lists, calling people), or financial help ($¥£€₩). To say "in any way" is mostly said to decline any association with some person, activity, idea, or event. The complete phrase, which you also commonly hear, is, "Not in any way shape or form."
In the example you gave the person speaking has listened to and watched the person being spoken about. Through that observation they have found nothing to suggest that the other person is stupid. The way they are using the phrase "in any way" is dismissing any connection between the other person and stupidity.