class_docstr: Produces labels for BROS.
  
  First set of labels is a binary value indicating whether a token is the
  start of a group. Second set of labels is a index indicating what the next
  token in the group is.
class_docstr_tok: ["Produces","labels","for","BROS.","First","set","of","labels","is","a","binary","value","indicating","whether","a","token","is","the","start","of","a","group",".","Second","set","of","labels","is","a","index","indicating","what","the","next","token","in","the","group","is","."]
code: def transform(self, out, labels):
      input_text = "".join(out.input_text)
      labels, groups = labels
      labels, pad_idx = self.pre_process_label(out, labels)
      start_token_labels = [pad_idx for _ in out.tokens]
      # Note that the default next token is 0. This is safe, as 0 is the
      # start token which no token should normally point to
      next_token_labels = [0 for _ in out.tokens]
  
      for group in groups:
          current_tag = "GROUP"
          prev_idx = None
          group_end = max([g["end"] for g in group["spans"]])
          for i, (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 labels do not align")
                  if not prev_idx and start_token_labels[i] != pad_idx:
                      LOGGER.warning("Overlapping start tokens found!")
                  if prev_idx and next_token_labels[i] != pad_idx:
                      LOGGER.warning("Overlapping next tokens found!")
                  if current_tag not in self.lookup:
                      LOGGER.warning(
                          "Attempting to encode unknown labels : {}, ignoring for now but this will likely not "
                          "result in desirable behaviour. Available labels are {}".format(
                              current_tag, self.lookup.keys()
                          )
                      )
                  if prev_idx is None:
                      # Only the first token needs a start token label
                      start_token_labels[i] = self.lookup[current_tag]
                      prev_idx = i
                  elif prev_idx is not None:
                      next_token_labels[prev_idx] = i
                      prev_idx = i
  
      return [start_token_labels, next_token_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 5 for calling the BROSEncoder obj's underlying member method code with example usage: obj.transform(out, labels) and returns: list