Building Param Groups

Hi All
I am looking for a logic to build the param groups . I know we have got method split on ,that just takes network layer indices and does rest of job. I want to build using own way to enhance knowledge.
I came across method add_param_Groups in pytorch documentation

Here is high level logic i can think of
Assume we want to build resnet model groups (m[0] m[6],m[1])
Here can be the logic

  1. Take children of group1 m[0] m[6]
  2. build dict p with key [‘params’]
    such that it contains list of weight params of all the children in the layer
  3. call add_param_group with this new dict whose params contain list of all the weight params say {params [ [] [] [] ] }
  4. similarly do for m[1]

if above logic is good please help writing the code…