Returns the module's attached ImageModuleInfo message, or None.

def get_image_module_info(module_or_spec, required=False):
  """Returns the module's attached ImageModuleInfo message, or None."""
  return module_or_spec.get_attached_message(
      IMAGE_MODULE_INFO_KEY, ImageModuleInfo, required=required)