class_docstr: TextSet wraps a set of texts with status.
docstr: Used to generate a TextSet for pairwise training.
  
  This method does the following:
  1. Generate all RelationPairs: (id1, id2Positive, id2Negative) from Relations.
  2. Join RelationPairs with corpus to transform id to indexedTokens.
  Note: Make sure that the corpus has been transformed by SequenceShaper and WordIndexer.
  3. For each pair, generate a TextFeature having Sample with:
  - feature of shape (2, text1Length + text2Length).
  - label of value [1 0] as the positive relation is placed before the negative one.
  
  :param relations: List or RDD of Relation.
  :param corpus1: TextSet that contains all id1 in relations. For each TextFeature in corpus1,
                  text must have been transformed to indexedTokens of the same length.
  :param corpus2: TextSet that contains all id2 in relations. For each TextFeature in corpus2,
                  text must have been transformed to indexedTokens of the same length.
  Note that if relations is a list, then corpus1 and corpus2 must both be LocalTextSet.
  If relations is RDD, then corpus1 and corpus2 must both be DistributedTextSet.
  
  :return: TextSet.
docstr_tok: ["Used","to","generate","a","TextSet","for","pairwise","training",".","This","method","does","the","following",":","1",".","Generate","all","RelationPairs",":","(","id1",",","id2Positive",",","id2Negative",")","from","Relations",".","2",".","Join","RelationPairs","with","corpus","to","transform","id","to","indexedTokens",".","Note",":","Make","sure","that","the","corpus","has","been","transformed","by","SequenceShaper","and","WordIndexer",".","3",".","For","each","pair",",","generate","a","TextFeature","having","Sample","with",":","-","feature","of","shape","(","2",",","text1Length","+","text2Length",")",".","-","label","of","value","[","1","0","]","as","the","positive","relation","is","placed","before","the","negative","one",".",":","param","relations",":","List","or","RDD","of","Relation",".",":","param","corpus1",":","TextSet","that","contains","all","id1","in","relations",".","For","each","TextFeature","in","corpus1",",","text","must","have","been","transformed","to","indexedTokens","of","the","same","length",".",":","param","corpus2",":","TextSet","that","contains","all","id2","in","relations",".","For","each","TextFeature","in","corpus2",",","text","must","have","been","transformed","to","indexedTokens","of","the","same","length",".","Note","that","if","relations","is","a","list",",","then","corpus1","and","corpus2","must","both","be","LocalTextSet",".","If","relations","is","RDD",",","then","corpus1","and","corpus2","must","both","be","DistributedTextSet",".",":","return",":","TextSet","."]
code: def from_relation_pairs(
      cls, relations, corpus1, corpus2, bigdl_type="float"
  ):
      """
      Used to generate a TextSet for pairwise training.
  
      This method does the following:
      1. Generate all RelationPairs: (id1, id2Positive, id2Negative) from Relations.
      2. Join RelationPairs with corpus to transform id to indexedTokens.
      Note: Make sure that the corpus has been transformed by SequenceShaper and WordIndexer.
      3. For each pair, generate a TextFeature having Sample with:
      - feature of shape (2, text1Length + text2Length).
      - label of value [1 0] as the positive relation is placed before the negative one.
  
      :param relations: List or RDD of Relation.
      :param corpus1: TextSet that contains all id1 in relations. For each TextFeature in corpus1,
                      text must have been transformed to indexedTokens of the same length.
      :param corpus2: TextSet that contains all id2 in relations. For each TextFeature in corpus2,
                      text must have been transformed to indexedTokens of the same length.
      Note that if relations is a list, then corpus1 and corpus2 must both be LocalTextSet.
      If relations is RDD, then corpus1 and corpus2 must both be DistributedTextSet.
  
      :return: TextSet.
      """
      if isinstance(relations, RDD):
          relations = relations.map(lambda x: x.to_tuple())
      elif isinstance(relations, list):
          relations = [relation.to_tuple() for relation in relations]
      else:
          invalidInputError(
              False, "relations should be RDD or list of Relation"
          )
      jvalue = callZooFunc(
          bigdl_type,
          "textSetFromRelationPairs",
          relations,
          corpus1,
          corpus2,
      )
      return TextSet(jvalue=jvalue)
  
imports: import six
  from bigdl.dllib.utils.common import JavaValue
  from bigdl.dllib.utils.file_utils import callZooFunc
  from pyspark import RDD
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 26 for calling the TextSet obj's underlying member method code with example usage: obj.from_relation_pairs(cls, relations, corpus1, corpus2, bigdl_type) and returns: TextSet