class_docstr: Data collator used for T5 span-masked language modeling.
  It is made sure that after masking the inputs are of length `data_args.max_seq_length` and targets are also of fixed length.
  For more information on how T5 span-masked language modeling works, one can take a look
  at the `official paper <https://arxiv.org/pdf/1910.10683.pdf>`__
  or the `official code for preprocessing <https://github.com/google-research/text-to-text-transfer-transformer/blob/master/t5/data/preprocessors.py>`__ .
  Args:
      tokenizer (:class:`~transformers.PreTrainedTokenizer` or :class:`~transformers.PreTrainedTokenizerFast`):
          The tokenizer used for encoding the data.
      noise_density (:obj:`float`):
          The probability with which to (randomly) mask tokens in the input.
      mean_noise_span_length (:obj:`float`):
          The average span length of the masked tokens.
      input_length (:obj:`int`):
          The expected input length after masking.
      target_length (:obj:`int`):
          The expected target length after masking.
      pad_token_id: (:obj:`int`):
          The pad token id of the model
      decoder_start_token_id: (:obj:`int):
          The decoder start token id of the model
class_docstr_tok: ["Data","collator","used","for","T5","span-masked","language","modeling",".","It","is","made","sure","that","after","masking","the","inputs","are","of","length","`","data_args.max_seq_length","`","and","targets","are","also","of","fixed","length",".","For","more","information","on","how","T5","span-masked","language","modeling","works",",","one","can","take","a","look","at","the","`","official","paper","<","https",":","\/\/arxiv.org\/pdf\/1910.10683.pdf",">","`","__","or","the","`","official","code","for","preprocessing","<","https",":","\/\/github.com\/google-research\/text-to-text-transfer-transformer\/blob\/master\/t5\/data\/preprocessors.py",">","`","__",".","Args",":","tokenizer","(",":","class",":","`","~transformers.PreTrainedTokenizer","`","or",":","class",":","`","~transformers.PreTrainedTokenizerFast","`",")",":","The","tokenizer","used","for","encoding","the","data",".","noise_density","(",":","obj",":","`","float","`",")",":","The","probability","with","which","to","(","randomly",")","mask","tokens","in","the","input",".","mean_noise_span_length","(",":","obj",":","`","float","`",")",":","The","average","span","length","of","the","masked","tokens",".","input_length","(",":","obj",":","`","int","`",")",":","The","expected","input","length","after","masking",".","target_length","(",":","obj",":","`","int","`",")",":","The","expected","target","length","after","masking",".","pad_token_id",":","(",":","obj",":","`","int","`",")",":","The","pad","token","id","of","the","model","decoder_start_token_id",":","(",":","obj",":","`","int",")",":","The","decoder","start","token","id","of","the","model"]
docstr: Sentinel ids creation given the indices that should be masked.
  The start indices of each mask are replaced by the sentinel ids in increasing
  order. Consecutive mask indices to be deleted are replaced with `-1`.
docstr_tok: ["Sentinel","ids","creation","given","the","indices","that","should","be","masked",".","The","start","indices","of","each","mask","are","replaced","by","the","sentinel","ids","in","increasing","order",".","Consecutive","mask","indices","to","be","deleted","are","replaced","with","`","-1","`","."]
code: def create_sentinel_ids(self, mask_indices):
      """
      Sentinel ids creation given the indices that should be masked.
      The start indices of each mask are replaced by the sentinel ids in increasing
      order. Consecutive mask indices to be deleted are replaced with `-1`.
      """
      start_indices = (
          mask_indices
          - np.roll(mask_indices, 1, axis=-1) * mask_indices
      )
      start_indices[:, 0] = mask_indices[:, 0]
  
      sentinel_ids = np.where(
          start_indices != 0,
          np.cumsum(start_indices, axis=-1),
          start_indices,
      )
      sentinel_ids = np.where(
          sentinel_ids != 0,
          (sentinel_ids + self.tokenizer.vocab_size - 101),
          0,
      )
      sentinel_ids -= mask_indices - start_indices
  
      return sentinel_ids
  
file_path: DeepKE/src/deepke/name_entity_re/cross/seq2seq/data_collator/t5mlm_data_collator.py
imports: import torch
  from dataclasses import dataclass
  from typing import Dict, Optional, Union
  import numpy
  from transformers import PreTrainedTokenizerBase, PreTrainedModel
  from transformers.file_utils import PaddingStrategy
label_desc: Use image node_id 2 for calling the DataCollatorForT5MLM obj's underlying member method code with example usage: obj.create_sentinel_ids(mask_indices) and returns: sentinel_ids