Bosses of hit CBS series How I Met Your Mother have apologized for Monday night's episode of the show, which included some racially insensitive themes.

The show featured Jason Segel's character Marshall going to China to larn the "art of slapping" from three masters, played by co-stars Josh Radnor, Cobie Smulders and Alyson Hannigan, all of whom were dressed to look Asian.

While the episode's intentions were to pay tribute to kung fu movies in a "silly and unabashedly immature" way, the episode angered viewers, who voiced their opinions on Twitter with the hashtag "#HowIMetYourRacism."

Carter Bays and Craig Thomas, the creators of HIMYM, have apologized for the episode.

"Hey guys, sorry this took so long. Craig and I want to say a few words about ?#HowIMetYourRacism," Bays wrote on Twitter. "With Monday's episode, we set out to make a silly and unabashedly immature homage to Kung Fu movies, a genre we've always loved...

"But along the way we offended people. We're deeply sorry, and we're grateful to everyone who spoke up to make us aware of it... We try to make a show that's universal, that anyone can watch and enjoy.

"We fell short of that this week, and feel terrible about it... To everyone we offended, I hope we can regain your friendship, and end this series on a note of goodwill. Thanks."

Thomas followed Bays' series of tweets with his own, writing, "I second everything Carter just tweeted - we love all #HIMYM fans and apologize that we caused offense."

The final episode of the series, which has run for nine seasons, airs on March 31.