docstr: Mask will be done on whole word that may across multiply token.
  
  Condition:
  * `mask_length` == word;
  * specify subword marker in order to find word boundary.
docstr_tok: ["Mask","will","be","done","on","whole","word","that","may","across","multiply","token",".","Condition",":","*","`","mask_length","`","==","word",";","*","specify","subword","marker","in","order","to","find","word","boundary","."]
code: def test_whole_word_mask(self):
      """Mask will be done on whole word that may across multiply token.
  
      Condition:
      * `mask_length` == word;
      * specify subword marker in order to find word boundary.
      """
      bart_noise = BARTNoising(
          vocab=[self.FAKE_VOCAB],
          mask_tok=self.MASK_TOK,
          mask_ratio=0.5,
          mask_length="word",
          is_joiner=True,
          replace_length=0,  # 0 to drop them, 1 to replace them with MASK
          # insert_ratio=0.0,
          # random_ratio=0.0,
          # Defalt: full_stop_token=[".", "?", "!"]
      )
      tokens = ["H￭", "ell￭", "o", "wor￭", "ld", "."]
      # start token of word are identified using subword marker
      token_starts = [True, False, False, True, False, True]
      self.assertEqual(bart_noise._is_word_start(tokens), token_starts)
  
      # 1. replace_length 0: "words" are dropped
      masked = bart_noise.apply(copy.copy(tokens))
      n_words = sum(token_starts)
      n_masked = math.ceil(n_words * bart_noise.mask_ratio)
      # print(f"word delete: {masked} / {tokens}")
      # self.assertEqual(len(masked), n_words - n_masked)
  
      # 2. replace_length 1: "words" are replaced with a single MASK
      bart_noise.replace_length = 1
      masked = bart_noise.apply(copy.copy(tokens))
      # print(f"whole word single mask: {masked} / {tokens}")
      # len(masked) depend on number of tokens in select word
      n_words = sum(token_starts)
      n_masked = math.ceil(n_words * bart_noise.mask_ratio)
      self.assertEqual(
          sum(1 if tok == self.MASK_TOK else 0 for tok in masked),
          n_masked,
      )
  
      # 3. replace_length -1: all tokens in "words" are replaced with MASK
      bart_noise.replace_length = -1
      masked = bart_noise.apply(copy.copy(tokens))
      # print(f"whole word multi mask: {masked} / {tokens}")
      self.assertEqual(len(masked), len(tokens))  # length won't change
      n_words = sum(token_starts)
      n_masked = math.ceil(n_words * bart_noise.mask_ratio)
      # number of mask_tok depend on number of tokens in selected word
      # number of MASK_TOK can be greater than n_masked
      self.assertTrue(
          sum(1 if tok == self.MASK_TOK else 0 for tok in masked)
          > n_masked
      )
  
imports: import unittest
  import copy
  import yaml
  import math
  from argparse import Namespace
  from onmt.transforms import get_transforms_cls, get_specials, make_transforms, TransformPipe
  from onmt.transforms.bart import BARTNoising
label_desc: Use image node_id 6 for calling the TestBARTNoising obj's underlying member method code with example usage: obj.test_whole_word_mask() without return types