code: def _get_ner_tags_and_mask(
      instance: Instance,
      input_field_to_attack: str,
      ignore_tokens: List[str],
  ):
      """
      Used for the NER task. Sets the num_ignore tokens, saves the original predicted tag and a 0/1
      mask in the position of the tags
      """
      # Set num_ignore_tokens
      num_ignore_tokens = 0
      input_field: TextField = instance[input_field_to_attack]  # type: ignore
      for token in input_field.tokens:
          if str(token) in ignore_tokens:
              num_ignore_tokens += 1
  
      # save the original tags and a 0/1 mask where the tags are
      tag_mask = []
      original_tags = []
      tag_field: SequenceLabelField = instance["tags"]  # type: ignore
      for label in tag_field.labels:
          if label != "O":
              tag_mask.append(1)
              original_tags.append(label)
              num_ignore_tokens += 1
          else:
              tag_mask.append(0)
      return num_ignore_tokens, tag_mask, original_tags
  
file_path: allennlp/allennlp/interpret/attackers/input_reduction.py
imports: from copy import deepcopy
  from typing import List, Tuple
  import heapq
  import numpy
  import torch
  from allennlp.common.util import JsonDict, sanitize
  from allennlp.data import Instance
  from allennlp.data.fields import TextField, SequenceLabelField
  from allennlp.interpret.attackers import utils
  from allennlp.interpret.attackers.attacker import Attacker
  from allennlp.predictors import Predictor
label_desc: Use image node_id 2 for calling a global function with example usage: _get_ner_tags_and_mask(instance, input_field_to_attack, ignore_tokens) and returns: num_ignore_tokens,  tag_mask,  original_tags