It was an ancient custom in Japan for a literate person to compose a poem as they lay dying. The custom has continued into modern Japan.