gramatická analýza: Divil se hloubaje nad básničkou.

The main conjugated verb is divil se. The subject for the verb is therefore masc. sg. hloubaje is a present verbal adverb, masculine sg form of hloubat. The verbal adverb adds information to the main verb, what the person was doing while he was in the state of being surprised.

Try paraphrasing the sentence using a prepositional phrase for "divit se" (s údivem or s překvapením), literally "with surprise he pondered over the poem". It is also possible to replace the verb hloubat with a more frequent přemýšlet.