code: def __init__(self, arr, fn):
      self.size = len(arr)
      arr = list(enumerate(arr))
      arr = group(arr, lambda x: fn(x[1]))
      arr = [([y[0] for y in x], x[0][1]) for x in arr]
      arr.sort(key=lambda x: fn(x[1]))
  
      self.arr = arr
  
imports: import os
  import pathlib
  import re
  import collections
  import functools
  import inspect
  import sys
  from typing import List, Union
  import torch
  from omegaconf import OmegaConf
  import sacrebleu
  from rouge_score import rouge_scorer, scoring
label_desc: Use image node_id 1 to create a new Reorderer object  with example: obj = Reorderer(arr, fn)