class_docstr: Generate potential merge of adjacent using a masked language model.
  
  Based off of:
      CLARE: Contextualized Perturbation for Textual Adversarial Attack" (Li et al, 2020) https://arxiv.org/abs/2009.07502
  
  Args:
      masked_language_model (Union[str|transformers.AutoModelForMaskedLM]): Either the name of pretrained masked language model from `transformers` model hub
          or the actual model. Default is `bert-base-uncased`.
      tokenizer (obj): The tokenizer of the corresponding model. If you passed in name of a pretrained model for `masked_language_model`,
          you can skip this argument as the correct tokenizer can be infered from the name. However, if you're passing the actual model, you must
          provide a tokenizer.
      max_length (int): The max sequence length the masked language model is designed to work with. Default is 512.
      window_size (int): The number of surrounding words to include when making top word prediction.
          For each position to merge, we take `window_size // 2` words to the left and `window_size // 2` words to the right and pass the text within the window
          to the masked language model. Default is `float("inf")`, which is equivalent to using the whole text.
      max_candidates (int): Maximum number of candidates to consider as replacements for each word. Replacements are
          ranked by model's confidence.
      min_confidence (float): Minimum confidence threshold each replacement word must pass.
class_docstr_tok: ["Generate","potential","merge","of","adjacent","using","a","masked","language","model",".","Based","off","of",":","CLARE",":","Contextualized","Perturbation","for","Textual","Adversarial","Attack","''","(","Li","et","al",",","2020",")","https",":","\/\/arxiv.org\/abs\/2009.07502","Args",":","masked_language_model","(","Union","[","str|transformers.AutoModelForMaskedLM","]",")",":","Either","the","name","of","pretrained","masked","language","model","from","`","transformers","`","model","hub","or","the","actual","model",".","Default","is","`","bert-base-uncased","`",".","tokenizer","(","obj",")",":","The","tokenizer","of","the","corresponding","model",".","If","you","passed","in","name","of","a","pretrained","model","for","`","masked_language_model","`",",","you","can","skip","this","argument","as","the","correct","tokenizer","can","be","infered","from","the","name",".","However",",","if","you","'re","passing","the","actual","model",",","you","must","provide","a","tokenizer",".","max_length","(","int",")",":","The","max","sequence","length","the","masked","language","model","is","designed","to","work","with",".","Default","is","512.","window_size","(","int",")",":","The","number","of","surrounding","words","to","include","when","making","top","word","prediction",".","For","each","position","to","merge",",","we","take","`","window_size","\/\/","2","`","words","to","the","left","and","`","window_size","\/\/","2","`","words","to","the","right","and","pass","the","text","within","the","window","to","the","masked","language","model",".","Default","is","`","float","(","``","inf","''",")","`",",","which","is","equivalent","to","using","the","whole","text",".","max_candidates","(","int",")",":","Maximum","number","of","candidates","to","consider","as","replacements","for","each","word",".","Replacements","are","ranked","by","model","'s","confidence",".","min_confidence","(","float",")",":","Minimum","confidence","threshold","each","replacement","word","must","pass","."]
docstr: Encodes ``text`` using an ``AutoTokenizer``, ``self._lm_tokenizer``.
  
  Returns a ``dict`` where keys are strings (like 'input_ids') and
  values are ``torch.Tensor``s. Moves tensors to the same device
  as the language model.
docstr_tok: ["Encodes","``","text","``","using","an","``","AutoTokenizer","``",",","``","self._lm_tokenizer","``",".","Returns","a","``","dict","``","where","keys","are","strings","(","like","'input_ids","'",")","and","values","are","``","torch.Tensor","``","s",".","Moves","tensors","to","the","same","device","as","the","language","model","."]
code: def _encode_text(self, text):
      """Encodes ``text`` using an ``AutoTokenizer``, ``self._lm_tokenizer``.
  
      Returns a ``dict`` where keys are strings (like 'input_ids') and
      values are ``torch.Tensor``s. Moves tensors to the same device
      as the language model.
      """
      encoding = self._lm_tokenizer(
          text,
          max_length=self.max_length,
          truncation=True,
          padding="max_length",
          return_tensors="pt",
      )
      return {k: v.to(utils.device) for k, v in encoding.items()}
  
file_path: TextAttack/textattack/transformations/word_merges/word_merge_masked_lm.py
imports: import re
  import torch
  from transformers import AutoModelForMaskedLM, AutoTokenizer
  from textattack.shared import utils
  from textattack.transformations.transformation import Transformation
label_desc: Use image node_id 2 for calling the WordMergeMaskedLM obj's underlying member method code with example usage: obj._encode_text(text) and returns: unknown