The proper use of participial phrases

Hi everyone,

I’d like to ask about the proper use of participial phrases in a sentense.
Here’s what I know so far:

When at the beginning of the sentense, a participial phrase will (and must) modify the grammatical subject of the whole sentense. Such as: Walking down the street, she holds my hand.

Yet when the participle is at the middle or end of the sentense, the modification behavior of such participial phrase is delusive to me. Since there’s no such definition of an adverbial participle or an adjective participle, I’m constantly confused about which part it is trying to modify. Here’s an example I try to assemble (it might not be the most confusing case though):

She talked with her kids walking down the street.
In such case, should the participle at the middle of it grammatically modify the closest noun, that is, “her kids”, or still follow the same rule as the one at the beginning of the sentense, that is, to modify “She”?

And in the case of punctuation, will that affect the modifying target of participle?
For example:
She talked affectionately, with her two kids, walking down the street.
In such case, will the participle modify “she” or the closest noun “two kids”?

Thanks!