code: def test_lm_precision(
      lang_model,
      lr_classifier,
      movie_sentiment_data,
      punctuation,
      stopwords,
  ):
      """
      Checks if the anchor precision exceeds the threshold
      """
      # unpack test data
      X_test = movie_sentiment_data["X_test"]
      short_examples = [
          i for i in range(len(X_test)) if len(X_test[i]) < 50
      ]
  
      # select 10 examples
      n = 10
      np.random.seed(0)
      idx = np.random.choice(short_examples, size=n, replace=False)
  
      # update test data
      X_test = [X_test[i] for i in idx]
  
      # fit and initialize predictor
      clf, preprocessor = lr_classifier
      predictor = predict_fcn("class", clf, preproc=preprocessor)
  
      # setup perturbation options
      perturb_opts = {
          "filling": "parallel",
          "sample_proba": 0.5,
          "temperature": 1.0,
          "top_n": 100,
          "frac_mask_templates": 0.1,
          "stopwords": stopwords,
          "punctuation": punctuation,
      }
  
      # initialize exaplainer
      explainer = AnchorText(
          predictor=predictor,
          sampling_strategy=AnchorText.SAMPLING_LANGUAGE_MODEL,
          language_model=lang_model,
          **perturb_opts,
      )
  
      for i in range(n):
          text = X_test[i]
  
          # compute explanation
          threshold = 0.95
          explanation = explainer.explain(text, threshold=threshold)
  
          # check precision to be greater than the threshold
          assert explanation.precision >= threshold
  
imports: import pytest
  from pytest_lazyfixture import lazy_fixture
  import string
  import numpy
  from typing import List
  from alibi.api.defaults import DEFAULT_META_ANCHOR, DEFAULT_DATA_ANCHOR
  from alibi.exceptions import PredictorCallError, PredictorReturnTypeError
  from alibi.explainers import AnchorText
  from alibi.explainers.anchors.text_samplers import Neighbors, load_spacy_lexeme_prob
  from alibi.explainers.anchors.language_model_text_sampler import LanguageModelSampler
  from alibi.explainers.tests.utils import predict_fcn
label_desc: Use image node_id 6 for calling a global function with example usage: test_lm_precision(lang_model, lr_classifier, movie_sentiment_data, punctuation, stopwords) without return types