code: def transform(self, y):
      all_labels = []
      for yi in y:
          labels, groups = yi
  
          # TODO: Add sorting of labels and groups before encoding, as
          # Doc2Dict tends to do bettter when labels and text appear in a
          # consistent order
  
          # NER Labels
          doc_labels = [
              {span["label"]: span["text"]} for span in labels
          ]
          # Group Labels
          doc_groups = []
          for group in groups:
              doc_groups.append(
                  [span["text"] for span in group["spans"]]
              )
          # Combine
          all_labels.append(json.dumps([doc_labels, 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 JointLabelingTextEncoder obj's underlying member method code with example usage: obj.transform(y) and returns: ret