class_docstr: A wrapper around TokenBlockDataset for BART dataset.
  
  Args:
      dataset (TokenBlockDataset): dataset to wrap
      sizes (List[int]): sentence lengths
      vocab (~fairseq.data.Dictionary): vocabulary
      mask_idx (int): dictionary index used for masked token
      mask_whole_words: only mask whole words. This should be a byte mask
          over vocab indices, indicating whether it is the beginning of a
          word. We will extend any mask to encompass the whole word.
      shuffle (bool, optional): shuffle the elements before batching.
        Default: ``True``
      seed: Seed for random number generator for reproducibility.
class_docstr_tok: ["A","wrapper","around","TokenBlockDataset","for","BART","dataset",".","Args",":","dataset","(","TokenBlockDataset",")",":","dataset","to","wrap","sizes","(","List","[","int","]",")",":","sentence","lengths","vocab","(","~fairseq.data.Dictionary",")",":","vocabulary","mask_idx","(","int",")",":","dictionary","index","used","for","masked","token","mask_whole_words",":","only","mask","whole","words",".","This","should","be","a","byte","mask","over","vocab","indices",",","indicating","whether","it","is","the","beginning","of","a","word",".","We","will","extend","any","mask","to","encompass","the","whole","word",".","shuffle","(","bool",",","optional",")",":","shuffle","the","elements","before","batching",".","Default",":","``","True","``","seed",":","Seed","for","random","number","generator","for","reproducibility","."]
code: def permute_sentences(self, source, p=1.0):
      full_stops = source == self.full_stop_index
      # Pretend it ends with a full stop so last span is a sentence
      full_stops[-2] = 1
  
      # Tokens that are full stops, where the previous token is not
      sentence_ends = (full_stops[1:] * ~full_stops[:-1]).nonzero(
          as_tuple=False
      ) + 2
      result = source.clone()
  
      num_sentences = sentence_ends.size(0)
      num_to_permute = math.ceil((num_sentences * 2 * p) / 2.0)
      substitutions = torch.randperm(num_sentences)[:num_to_permute]
      ordering = torch.arange(0, num_sentences)
      ordering[substitutions] = substitutions[
          torch.randperm(num_to_permute)
      ]
  
      # Ignore <bos> at start
      index = 1
      for i in ordering:
          sentence = source[
              (sentence_ends[i - 1] if i > 0 else 1) : sentence_ends[i]
          ]
          result[index : index + sentence.size(0)] = sentence
          index += sentence.size(0)
      return result
  
imports: import math
  import numpy
  import torch
  from .None import FairseqDataset, data_utils
label_desc: Use image node_id 6 for calling the DenoisingDataset obj's underlying member method code with example usage: obj.permute_sentences(source, p) and returns: result