class_docstr: Transforms an input by replacing its tokens with words of mask language
  predicted.
  To accelerate transformation for long text, input single sentence to
  language model rather than whole text.
class_docstr_tok: ["Transforms","an","input","by","replacing","its","tokens","with","words","of","mask","language","predicted",".","To","accelerate","transformation","for","long","text",",","input","single","sentence","to","language","model","rather","than","whole","text","."]
docstr: Get indices of substitute words.
  
  :param list words: original tokens without sentence split
  :param list sentences_tokens: sentence token lists split from words
  :param list legal_indices: legal indices which are allowed substituted
  :return: list sub_indices, sub_sentences, sub_sent_indices
docstr_tok: ["Get","indices","of","substitute","words",".",":","param","list","words",":","original","tokens","without","sentence","split",":","param","list","sentences_tokens",":","sentence","token","lists","split","from","words",":","param","list","legal_indices",":","legal","indices","which","are","allowed","substituted",":","return",":","list","sub_indices",",","sub_sentences",",","sub_sent_indices"]
code: def _get_relate_sub_info(
      self, words, sentences_tokens, legal_indices
  ):
      r"""
      Get indices of substitute words.
  
      :param list words: original tokens without sentence split
      :param list sentences_tokens: sentence token lists split from words
      :param list legal_indices: legal indices which are allowed substituted
      :return: list sub_indices, sub_sentences, sub_sent_indices
      """
      sentences_indices = []
      idx = 0
  
      for sentence_tokens in sentences_tokens:
          sentences_indices.append(
              list(range(idx, idx + len(sentence_tokens)))
          )
          idx += len(sentence_tokens)
  
      trans_num = self.get_trans_cnt(len(words))
      sub_indices = sorted(self.sample_num(legal_indices, trans_num))
      valid_sub_indices = []
      sub_sentences = []
      sub_sent_indices = []
  
      for sub_index in sub_indices:
          for idx, sentence_indices in enumerate(sentences_indices):
              # skip out of index cases
              if (
                  sub_index in sentence_indices
                  and sentence_indices.index(sub_index)
                  < self.max_sent_size
              ):
                  valid_sub_indices.append(sub_index)
                  sub_sentences.append(idx)
                  sub_sent_indices.append(
                      sentence_indices.index(sub_index)
                  )
  
      return valid_sub_indices, sub_sentences, sub_sent_indices
  
file_path: textflint/textflint/generation/transformation/UT/mlm_suggestion.py
imports: import torch
  from copy import copy
  from collections import defaultdict
  from ....common import device
  from ...transformation.word_substitute import WordSubstitute
  from ....common.settings import BERT_MODEL_NAME
  from ....common.utils.list_op import trade_off_sub_words
label_desc: Use image node_id 8 for calling the MLMSuggestion obj's underlying member method code with example usage: obj._get_relate_sub_info(words, sentences_tokens, legal_indices) and returns: valid_sub_indices,  sub_sentences,  sub_sent_indices