In the beginning of The Wolverine (2013) movie, it was shown that a few soldiers commit suicide. Yashida was one of the soldiers about to commit suicide, but Wolverine stopped him. What was the reason behind committing suicide?
Nagasaki was about to be hit with an atomic bomb. Hiroshima had been devastated by a similar bomb just three days earlier. Watching the bomb fall, they knew there was no escape and that they were about to die.
But they viewed themselves as samurai, and adhered to the Code of Bushido.
The previous answers have got it right, but I thought I'd add some details (just for fun.) I majored in Japanese history in college, and I wrote my senior thesis on front line battles in the Asia/Pacific theater of WWII. So forgive me if I'm long winded, I just like my details...
It is true that there were soldiers in the Japanese military who held to the ideals of the Bushido Code. Not all of them, not even a majority of them, but enough that this scene is "real enough" for fantasy. What's interesting to me though is that as a culture we tend to focus on that small percentage of soldiers and, quite often, we assume they are not a minority, but are the vast majority instead. I think the greater question becomes, "why do modern film makers often assume Japanese soldiers are willing to commit seppuku rather than retreat or fight to their death?"
The immediate reason for this is that sepukku among the Japanese is a common trope, not just in American film but also in Japanese entertainment in general. Anyone who grew up reading manga and watching anime knows this ;). There are two related reasons why it shows up so much in Japanese culture. Firstly, Japan has been trained/educated to identify with it's Samurai past. Secondly, that Samurai past has mostly been interpreted from books like The Bushido Code and The Book of Five Rings, both of which teach this "death before surrender" mentality.
There's a big problem with this interpretation of the Samurai: it's almost wholly historically inaccurate.
A little background: the last major conflict that involved Samurai (or at least Samurai like warriors) was the Sengoku, a century long civil war stretching from roughly 1500 ~ 1600 AD. During that time the Samurai fought routinely, and, frankly, retreated just as routinely. Any military general with any desire to actually win a conflict knows you need to preserve your forces to fight another day if you are losing, the Samurai were no different. It should also be noted that Samurai of the sengoku routinely did things that would be considered dishonorably by today's standards (burning villages, switching sides opportunistically, other things you'd expect from a multi front civil war...)
So, if it's not historically accurate, where did this "death before dishonor" actually come from then?
Well, it was codified in The Book of Five Rings and The Bushido Code. But, interestingly enough, both of those books were written roughly 40 years after the conflict was over in about 1640. By that time the Samurai had been retired as warriors and were, for all intents and purposes, strictly bureaucrats and politicians. Some of which worried that the Samurai, because of their new positions, were becoming soft. So they wrote some highly idealized rules they felt all Samurai should follow. But, and this is important, during the Tokugawa era (1600 ~ 1857), those books were largely ignored and the Samurai were, on the whole, about as honorable as your average citizen (not bad, just not "death before dishonor"). For example, pretty much the only time anyone committed sepukku was when commanded to, often because of presumed disloyalty to leadership. Thus, during the Tokugawa, it was merely a form of execution for the bureaucrats of Japan.
So if the historical Samurai had no interest in the Bushido Code, why does modern Japan?
Well, that goes back to 1853, when Japan was forceably opened to western culture by the incursion of Matthew Perry'sBlack Ships. Japan started to westernize rapidly, and before terribly long there was a feeling, nationally, of a loss of natural identity as western society and culture entered Japan.
Around 1890 there was a general backlash against western culture, and one of the main fixtures of this backlash was a sudden interest in both the Bushido Code and the Book of Five Rings. It was taught, at that time, that all Japan was descended from Samurai (which is false, they were a small percentage of the population), and that all Samurai would rather die honorably in battle than suffer defeat. Which, as noted, is something the Bushido Code taught, but was actually never used by a significant percentage of actual Samurai.
But nevermind that, the point is that the concept entered into the public concious. As a result popular entertainment started to create shows/books/art/magazine articles that featured these highly principled, always ready to die Samurai (think Kurosawa). This had a small lul after WWII (for obvious reasons), but came back in full force through the 70s and 80s. Which, incidentally, coincided with a rising interest in Japanese Media over here in America (and the world over, as I recall.)
Thus we inherited the widely held belief that the Japanese, as a people, are willing to die before they are dishonored. A notion that is, at best, a current partial truth and historically false.
But hey, it makes for a good story. And that's why you see it in the movie Wolverine and several other American movies that involve Japanese people at war.
This dates back to the samurai. It is known as Seppuku or Harakiri. The samurai used to do it because they preferred to die with honor rather than get captured by the enemy.