class_docstr: Noise from BART.
class_docstr_tok: ["Noise","from","BART","."]
code: def __init__(
      self,
      vocab,
      mask_tok=DefaultTokens.MASK,
      mask_ratio=0.0,
      insert_ratio=0.0,
      permute_sent_ratio=0.0,
      poisson_lambda=3.0,
      replace_length=-1,
      rotate_ratio=0.0,
      mask_length="subword",
      random_ratio=0.0,
      is_joiner=False,
      full_stop_token=DefaultTokens.SENT_FULL_STOPS,
  ):
      if vocab is None:
          raise ValueError(
              "Inject BART noise requires a valid vocabulary."
          )
      self.vocab = vocab
  
      self.mask_tok = mask_tok
  
      self.mask_ratio = mask_ratio
      self.random_ratio = random_ratio
      self.insert_ratio = insert_ratio
      self.rotate_ratio = rotate_ratio
      self.permute_sent_ratio = permute_sent_ratio
  
      self.full_stop_token = full_stop_token
  
      # -1: keep everything (i.e. 1 mask per token)
      #  0: replace everything (i.e. no mask)
      #  1: 1 mask per span
      if replace_length not in [-1, 0, 1]:
          raise ValueError(
              f"invalid arg: replace_length={replace_length}"
          )
      self.replace_length = replace_length
  
      if mask_length not in ["subword", "word", "span-poisson"]:
          raise ValueError(f"invalid arg: mask-length={mask_length}")
      if mask_length == "subword" and replace_length not in [0, 1]:
          raise ValueError(
              "if using subwords, use replace-length=1 or 0"
          )
  
      if mask_length == "subword" or is_joiner is None:
          # view each subword as word start / input is word level token
          self._is_word_start = word_start_finder(ignore_subword=True)
      else:
          self._is_word_start = word_start_finder(is_joiner=is_joiner)
  
      self.mask_span_distribution = None
      if mask_length == "span-poisson":
          self.mask_span_distribution = self._make_poisson(
              poisson_lambda
          )
      self.mask_length = mask_length
      self.poisson_lambda = poisson_lambda
  
imports: import math
  import numpy
  import torch
  from typing import Sequence, Callable
  from onmt.constants import DefaultTokens, SubwordMarker
  from onmt.transforms import register_transform
  from .transform import Transform
label_desc: Use image node_id 1 to create a new BARTNoising object from inherited base classes: object with example: obj = BARTNoising(vocab, mask_tok, mask_ratio, insert_ratio, permute_sent_ratio, poisson_lambda, replace_length, rotate_ratio, mask_length, random_ratio, is_joiner, full_stop_token)