code: def transform(self, y):
      all_labels = []
      for yi in y:
          doc_groups = []
          _, groups = yi
          for group in groups:
              # TODO: Add sorting of group tokens before encoding, as Doc2Dict tends to do
              # bettter when labels and text appear in a consistent order
  
              # List of strings, where each string is on of the spans of the group
              doc_groups.append(
                  [span["text"] for span in group["spans"]]
              )
          all_labels.append(json.dumps(doc_groups))
      ret = super().transform(all_labels)
      return ret
  
imports: from abc import ABCMeta
  import logging
  import json
  import numpy
  from finetune.encoding.target_encoders import BaseEncoder, Seq2SeqLabelEncoder, SequenceLabelingEncoder
label_desc: Use image node_id 1 for calling the GroupLabelingTextEncoder obj's underlying member method code with example usage: obj.transform(y) and returns: ret