class_docstr: Data collator used for language modeling. Inputs are dynamically padded to the maximum length of a batch if they
  are not all of the same length.
  
  Args:
      tokenizer ([`PreTrainedTokenizer`] or [`PreTrainedTokenizerFast`]):
          The tokenizer used for encoding the data.
      mlm (`bool`, *optional*, defaults to `True`):
          Whether or not to use masked language modeling. If set to `False`, the labels are the same as the inputs
          with the padding tokens ignored (by setting them to -100). Otherwise, the labels are -100 for non-masked
          tokens and the value to predict for the masked token.
      mlm_probability (`float`, *optional*, defaults to 0.15):
          The probability with which to (randomly) mask tokens in the input, when `mlm` is set to `True`.
      pad_to_multiple_of (`int`, *optional*):
          If set will pad the sequence to a multiple of the provided value.
      return_tensors (`str`):
          The type of Tensor to return. Allowable values are "np", "pt" and "tf".
  
  <Tip>
  
  For best performance, this data collator should be used with a dataset having items that are dictionaries or
  BatchEncoding, with the `"special_tokens_mask"` key, as returned by a [`PreTrainedTokenizer`] or a
  [`PreTrainedTokenizerFast`] with the argument `return_special_tokens_mask=True`.
  
  </Tip>
class_docstr_tok: ["Data","collator","used","for","language","modeling",".","Inputs","are","dynamically","padded","to","the","maximum","length","of","a","batch","if","they","are","not","all","of","the","same","length",".","Args",":","tokenizer","(","[","`","PreTrainedTokenizer","`","]","or","[","`","PreTrainedTokenizerFast","`","]",")",":","The","tokenizer","used","for","encoding","the","data",".","mlm","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","or","not","to","use","masked","language","modeling",".","If","set","to","`","False","`",",","the","labels","are","the","same","as","the","inputs","with","the","padding","tokens","ignored","(","by","setting","them","to","-100",")",".","Otherwise",",","the","labels","are","-100","for","non-masked","tokens","and","the","value","to","predict","for","the","masked","token",".","mlm_probability","(","`","float","`",",","*","optional","*",",","defaults","to","0.15",")",":","The","probability","with","which","to","(","randomly",")","mask","tokens","in","the","input",",","when","`","mlm","`","is","set","to","`","True","`",".","pad_to_multiple_of","(","`","int","`",",","*","optional","*",")",":","If","set","will","pad","the","sequence","to","a","multiple","of","the","provided","value",".","return_tensors","(","`","str","`",")",":","The","type","of","Tensor","to","return",".","Allowable","values","are","``","np","''",",","``","pt","''","and","``","tf","''",".","<","Tip",">","For","best","performance",",","this","data","collator","should","be","used","with","a","dataset","having","items","that","are","dictionaries","or","BatchEncoding",",","with","the","`","``","special_tokens_mask","''","`","key",",","as","returned","by","a","[","`","PreTrainedTokenizer","`","]","or","a","[","`","PreTrainedTokenizerFast","`","]","with","the","argument","`","return_special_tokens_mask=True","`",".","<","\/Tip",">"]
code: def torch_call(
      self, examples: List[Union[List[int], Any, Dict[str, Any]]]
  ) -> Dict[str, Any]:
      # Handle dict or lists with proper padding and conversion to tensor.
      if isinstance(examples[0], Mapping):
          batch = self.tokenizer.pad(
              examples,
              return_tensors="pt",
              pad_to_multiple_of=self.pad_to_multiple_of,
          )
      else:
          batch = {
              "input_ids": _torch_collate_batch(
                  examples,
                  self.tokenizer,
                  pad_to_multiple_of=self.pad_to_multiple_of,
              )
          }
  
      # If special token mask has been preprocessed, pop it from the dict.
      special_tokens_mask = batch.pop("special_tokens_mask", None)
      if self.mlm:
          batch["input_ids"], batch["labels"] = self.torch_mask_tokens(
              batch["input_ids"],
              special_tokens_mask=special_tokens_mask,
          )
      else:
          labels = batch["input_ids"].clone()
          if self.tokenizer.pad_token_id is not None:
              labels[labels == self.tokenizer.pad_token_id] = -100
          batch["labels"] = labels
      return batch
  
imports: import random
  import warnings
  from collections.abc import Mapping
  from dataclasses import dataclass
  from random import randint
  from typing import Any, Callable, Dict, List, NewType, Optional, Tuple, Union
  import numpy
  from ..models.bert import BertTokenizer, BertTokenizerFast
  from ..tokenization_utils_base import PreTrainedTokenizerBase
  from ..utils import PaddingStrategy
label_desc: Use image node_id 5 for calling the DataCollatorForLanguageModeling obj's underlying member method code with example usage: obj.torch_call(examples) and returns: batch