Tensorrt with dynamic input

Tensorrt7 support dynamic input.
I am confused with how to to use this feature.

In this sample, if I addInput with some dimensions with -1, createNetworkV2 with kEXPLICIT_BATCH is required?And create an optimization profile is required?