code: def _convert_word_to_ids_tensor(
      word, tokenizer, vocab, namespace, all_cases
  ):
      # function does NOT strip special tokens if tokenizer adds them
      if all_cases:
          words_list = [word.lower(), word.title(), word.upper()]
      else:
          words_list = [word]
      ids = []
      for w in words_list:
          # if vocab is None, use tokenizer vocab (only works for Huggingface PreTrainedTokenizer)
          if vocab:
              tokens = tokenizer.tokenize(w)
              ids.append(
                  torch.tensor(
                      [
                          vocab.get_token_index(t.text, namespace)
                          for t in tokens
                      ]
                  )
              )
          else:
              ids.append(
                  torch.tensor(tokenizer.tokenizer(w)["input_ids"])
              )
      return ids
  
file_path: allennlp/allennlp/fairness/bias_utils.py
imports: import torch
  import json
  from os import PathLike
  from typing import List, Tuple, Union, Optional
  from allennlp.common.file_utils import cached_path
  from allennlp.data import Vocabulary
  from allennlp.data.tokenizers.tokenizer import Tokenizer
label_desc: Use image node_id 1 for calling a global function with example usage: _convert_word_to_ids_tensor(word, tokenizer, vocab, namespace, all_cases) and returns: ids