class_docstr: A helper class that represents a string that can be attacked.
  
  Models that take multiple sentences as input separate them by ``SPLIT_TOKEN``.
  Attacks "see" the entire input, joined into one string, without the split token.
  
  ``AttackedText`` instances that were perturbed from other ``AttackedText``
  objects contain a pointer to the previous text
  (``attack_attrs["previous_attacked_text"]``), so that the full chain of
  perturbations might be reconstructed by using this key to form a linked
  list.
  
  Args:
     text (string): The string that this AttackedText represents
     attack_attrs (dict): Dictionary of various attributes stored
         during the course of an attack.
class_docstr_tok: ["A","helper","class","that","represents","a","string","that","can","be","attacked",".","Models","that","take","multiple","sentences","as","input","separate","them","by","``","SPLIT_TOKEN","``",".","Attacks","``","see","''","the","entire","input",",","joined","into","one","string",",","without","the","split","token",".","``","AttackedText","``","instances","that","were","perturbed","from","other","``","AttackedText","``","objects","contain","a","pointer","to","the","previous","text","(","``","attack_attrs","[","``","previous_attacked_text","''","]","``",")",",","so","that","the","full","chain","of","perturbations","might","be","reconstructed","by","using","this","key","to","form","a","linked","list",".","Args",":","text","(","string",")",":","The","string","that","this","AttackedText","represents","attack_attrs","(","dict",")",":","Dictionary","of","various","attributes","stored","during","the","course","of","an","attack","."]
docstr: Align AttackedText's `words` with target model's tokenization scheme
  (e.g. word, character, subword). Specifically, we map each word to list
  of indices of tokens that compose the word (e.g. embedding --> ["em",
  "##bed", "##ding"])
  
  Args:
      model_wrapper (textattack.models.wrappers.ModelWrapper): ModelWrapper of the target model
  
  Returns:
      word2token_mapping (dict[int, list[int]]): Dictionary that maps i-th word to list of indices.
docstr_tok: ["Align","AttackedText","'s","`","words","`","with","target","model","'s","tokenization","scheme","(","e.g",".","word",",","character",",","subword",")",".","Specifically",",","we","map","each","word","to","list","of","indices","of","tokens","that","compose","the","word","(","e.g",".","embedding","--",">","[","``","em","''",",","''","#","#","bed","''",",","``","#","#","ding","''","]",")","Args",":","model_wrapper","(","textattack.models.wrappers.ModelWrapper",")",":","ModelWrapper","of","the","target","model","Returns",":","word2token_mapping","(","dict","[","int",",","list","[","int","]","]",")",":","Dictionary","that","maps","i-th","word","to","list","of","indices","."]
code: def align_with_model_tokens(
      self, model_wrapper: textattack.models.wrappers.ModelWrapper
  ) -> Dict[int, Iterable[int]]:
      """Align AttackedText's `words` with target model's tokenization scheme
      (e.g. word, character, subword). Specifically, we map each word to list
      of indices of tokens that compose the word (e.g. embedding --> ["em",
      "##bed", "##ding"])
  
      Args:
          model_wrapper (textattack.models.wrappers.ModelWrapper): ModelWrapper of the target model
  
      Returns:
          word2token_mapping (dict[int, list[int]]): Dictionary that maps i-th word to list of indices.
      """
      tokens = model_wrapper.tokenize(
          [self.tokenizer_input], strip_prefix=True
      )[0]
      word2token_mapping = {}
      j = 0
      last_matched = 0
  
      for i, word in enumerate(self.words):
          matched_tokens = []
          while j < len(tokens) and len(word) > 0:
              token = tokens[j].lower()
              idx = word.lower().find(token)
              if idx == 0:
                  word = word[idx + len(token) :]
                  matched_tokens.append(j)
                  last_matched = j
              j += 1
  
          if not matched_tokens:
              word2token_mapping[i] = None
              j = last_matched
          else:
              word2token_mapping[i] = matched_tokens
  
      return word2token_mapping
  
imports: from __future__ import annotations
  from collections import OrderedDict
  import math
  from typing import Dict, Iterable, List, Optional, Set, Tuple
  import flair
  from flair.data import Sentence
  import numpy
  import torch
  import textattack
  from .utils import device, words_from_text
label_desc: Use image node_id 25 for calling the AttackedText obj's underlying member method code with example usage: obj.align_with_model_tokens(model_wrapper) and returns: word2token_mapping