parameters: (paths, D_groups, H_groups)
return_statement: return ordered_paths
docstring: Reorders the given paths in order of aggregation of ranks for D and H parallellism respectively
         and returns the ordered dict
docstring_summary: Reorders the given paths in order of aggregation of ranks for D and H parallellism respectively
         and returns the ordered dict
docstring_tokens: Reorders the given paths in order of aggregation of ranks for D and H parallellism respectively and returns the ordered dict
function: def _order_paths(paths, D_groups, H_groups):
      """Reorders the given paths in order of aggregation of ranks for D and H parallellism respectively
         and returns the ordered dict"""
  
      trainer_options_path_tuples = []
      world_rank = _utils.state_dict_trainer_options_world_rank_key()
  
      for path in paths:
          trainer_options_path_tuples.append((_checkpoint_storage.load(path,
              key=_utils.state_dict_trainer_options_key()), path))
  
      # sort paths according to rank
      sorted_paths = [path for _, path in sorted(trainer_options_path_tuples,
          key=lambda trainer_options_path_pair: trainer_options_path_pair[0][world_rank])]
      
      ordered_paths = dict()
      ordered_paths['D'] = [[sorted_paths[i] for i in D_groups[group_id]] for group_id in range(len(D_groups))]
      ordered_paths['H'] = [[sorted_paths[i] for i in H_groups[group_id]] for group_id in range(len(H_groups))]
  
      return ordered_paths
function_tokens: def _order_paths ( paths , D_groups , H_groups ) : trainer_options_path_tuples = [ ] world_rank = _utils . state_dict_trainer_options_world_rank_key ( ) for path in paths : trainer_options_path_tuples . append ( ( _checkpoint_storage . load ( path , key = _utils . state_dict_trainer_options_key ( ) ) , path ) ) # sort paths according to rank sorted_paths = [ path for _ , path in sorted ( trainer_options_path_tuples , key = lambda trainer_options_path_pair : trainer_options_path_pair [ 0 ] [ world_rank ] ) ] ordered_paths = dict ( ) ordered_paths [ 'D' ] = [ [ sorted_paths [ i ] for i in D_groups [ group_id ] ] for group_id in range ( len ( D_groups ) ) ] ordered_paths [ 'H' ] = [ [ sorted_paths [ i ] for i in H_groups [ group_id ] ] for group_id in range ( len ( H_groups ) ) ] return ordered_paths