Microscopic Derivation of Multichannel Hubbard Models for Ultracold Nonreactive Molecules in an Optical Lattice