class_docstr: Produces labels for a group relation model.
  
  Labels are of shape [n_groups, seq_len], where each element is a 0 or 1 and
  represents whether a token belongs to a certain group, and where the last
  group represents the pad group
class_docstr_tok: ["Produces","labels","for","a","group","relation","model",".","Labels","are","of","shape","[","n_groups",",","seq_len","]",",","where","each","element","is","a","0","or","1","and","represents","whether","a","token","belongs","to","a","certain","group",",","and","where","the","last","group","represents","the","pad","group"]
code: def transform(self, out, labels):
      input_text = "".join(out.input_text)
      labels, groups = labels
  
      if len(groups) > self.n_groups - 1:
          print(groups)
          raise ValueError(
              f"{len(groups)} groups found, more than n_groups!"
          )
  
      # Build relation matrix
      encoded_labels = [
          [0 for _ in range(len(out.tokens))]
          for _ in range(self.n_groups - 1)
      ]
      # Final group is reserved for pad
      # Tokens default to this group
      encoded_labels.append([1 for _ in range(len(out.tokens))])
      for i, group in enumerate(groups):
          group_end = max([g["end"] for g in group["spans"]])
          for j, (start, end, text) in enumerate(
              zip(out.token_starts, out.token_ends, out.tokens)
          ):
              if group_end < (start + end + 1) // 2:
                  break
              overlap, agree = self.group_overlaps(
                  group, start, end, text, input_text
              )
              if overlap:
                  if not agree:
                      raise ValueError("Tokens and groups do not align")
                  encoded_labels[i][j] = 1
                  encoded_labels[-1][j] = 0
  
      return encoded_labels
  
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 3 for calling the GroupRelationEncoder obj's underlying member method code with example usage: obj.transform(out, labels) and returns: encoded_labels