docstr: Find indices in words which can be perturbed.
  
  Parameters
  ----------
  punctuation
      String of punctuation characters.
  stopwords
      List of stopwords.
  **kwargs
      Other arguments. Not used.
docstr_tok: ["Find","indices","in","words","which","can","be","perturbed",".","Parameters","--","--","--","--","--","punctuation","String","of","punctuation","characters",".","stopwords","List","of","stopwords",".","*","*","kwargs","Other","arguments",".","Not","used","."]
code: def get_sample_ids(
      self,
      punctuation: str = string.punctuation,
      stopwords: Optional[List[str]] = None,
      **kwargs,
  ) -> None:
      """
      Find indices in words which can be perturbed.
  
      Parameters
      ----------
      punctuation
          String of punctuation characters.
      stopwords
          List of stopwords.
      **kwargs
          Other arguments. Not used.
      """
      # transform stopwords to lowercase
      if stopwords:
          stopwords = [w.lower().strip() for w in stopwords]
  
      # Initialize list of indices allowed to be perturbed
      ids_sample = list(np.arange(len(self.head_tokens)))
  
      # Define partial function for stopwords checking
      is_stop_word = partial(
          self.model.is_stop_word,
          tokenized_text=self.head_tokens,
          punctuation=punctuation,
          stopwords=stopwords,
      )
  
      # lambda expressions to check for a subword
      subword_cond = lambda token, idx: self.model.is_subword_prefix(
          token
      )  # noqa: E731
      # lambda experssion to check for a stopword
      stopwords_cond = lambda token, idx: is_stop_word(
          start_idx=idx
      )  # noqa: E731
      # lambda expression to check for punctuation
      punctuation_cond = lambda token, idx: self.model.is_punctuation(
          token, punctuation
      )  # noqa: E731
  
      # Gather all in a list of conditions
      conds = [punctuation_cond, stopwords_cond, subword_cond]
  
      # Remove indices of the tokens that are not allowed to be masked
      for i, token in enumerate(self.head_tokens):
          if any([cond(token, i) for cond in conds]):
              ids_sample.remove(i)
  
      # Save the indices allowed to be masked and the corresponding mapping.
      # The anchor base algorithm alters indices one by one. By saving the mapping
      # and sending only the initial token of a word, we avoid unnecessary sampling.
      # E.g. word = token1 ##token2. Instead of trying two anchors (1 0), (1, 1) - which are
      # equivalent because we take the full word, just try one (1)
      self.ids_sample = np.array(ids_sample)
      self.ids_mapping = {i: id for i, id in enumerate(self.ids_sample)}
  
imports: import string
  from functools import partial
  from typing import Dict, List, Optional, Tuple
  import numpy
  import tensorflow
  from alibi.utils.lang_model import LanguageModel
  from alibi.explainers.anchors.text_samplers import AnchorTextSampler
label_desc: Use image node_id 2 for calling the LanguageModelSampler obj's underlying member method code with example usage: obj.get_sample_ids(punctuation, stopwords) without return types