class_docstr: Synonyms. For implementation details, see
  https://github.com/GEM-benchmark/NL-Augmenter/blob/main/nlaugmenter/transformations/synonym_substitution/transformation.py
  
  This perturbation adds noise to a text source by randomly inserting synonyms of randomly selected
  words excluding punctuations and stopwords.
  The space of synonyms depends on WordNet and could be limited. The transformation might introduce
  non-grammatical segments.
  
  Perturbation example:
  
  **Input:**
      This was a good movie, would watch again.
  
  **Output:**
      This was a dependable movie, would determine again.
class_docstr_tok: ["Synonyms",".","For","implementation","details",",","see","https",":","\/\/github.com\/GEM-benchmark\/NL-Augmenter\/blob\/main\/nlaugmenter\/transformations\/synonym_substitution\/transformation.py","This","perturbation","adds","noise","to","a","text","source","by","randomly","inserting","synonyms","of","randomly","selected","words","excluding","punctuations","and","stopwords",".","The","space","of","synonyms","depends","on","WordNet","and","could","be","limited",".","The","transformation","might","introduce","non-grammatical","segments",".","Perturbation","example",":","*","*","Input",":","*","*","This","was","a","good","movie",",","would","watch","again",".","*","*","Output",":","*","*","This","was","a","dependable","movie",",","would","determine","again","."]
code: def __init__(self, prob: float):
      # Assign parameters to instance variables
      self.prob: float = prob
  
      # Initialize the model with spaCy: https://spacy.io/models/en
      try:
          self.spacy_model = spacy.load("en_core_web_sm")
      except OSError:
          spacy.cli.download("en_core_web_sm")  # type: ignore
          self.spacy_model = spacy.load("en_core_web_sm")
  
      output_dir = os.path.join(
          "benchmark_output", "perturbations", self.name
      )
      Path(output_dir).mkdir(parents=True, exist_ok=True)
      nltk.data.path.append(output_dir)
      try:
          # We cannot use wordnet.synsets directly since it's not thread-safe. So we copy the synsets to
          # wordnet_synonyms.json and use that in combination with _morphy (as done in the original wordnet.synsets).
          wordnet.ensure_loaded()
      except LookupError:
          if not os.path.exists(
              os.path.join(output_dir, "corpora/wordnet")
          ):
              nltk.download("wordnet", download_dir=output_dir)
          if not os.path.exists(
              os.path.join(output_dir, "corpora/omw-1.4")
          ):
              nltk.download("omw-1.4", download_dir=output_dir)
      wordnet.ensure_loaded()
  
      target_path = os.path.join(output_dir, self.FILE_NAME)
      ensure_file_downloaded(
          source_url=self.SOURCE_URI, target_path=target_path
      )
      with open(target_path) as f:
          self.wordnet_synonyms: Dict[str, List[str]] = json.load(f)
  
file_path: H2O/h2o_hf/helm/src/helm/benchmark/augmentations/synonym_perturbation.py
imports: from dataclasses import dataclass
  import json
  import os
  from random import Random
  from pathlib import Path
  from typing import Dict, List
  import nltk
  from nltk.corpus import wordnet
  import spacy
  from helm.common.general import match_case, ensure_file_downloaded
  from .perturbation_description import PerturbationDescription
  from .perturbation import Perturbation
label_desc: Use image node_id 1 to create a new SynonymPerturbation object from inherited base classes: Perturbation with example: obj = SynonymPerturbation(prob)