class_docstr: Data collator used for sentence order prediction task.
  
  - collates batches of tensors, honoring their tokenizer's pad_token
  - preprocesses batches for both masked language modeling and sentence order prediction
class_docstr_tok: ["Data","collator","used","for","sentence","order","prediction","task",".","-","collates","batches","of","tensors",",","honoring","their","tokenizer","'s","pad_token","-","preprocesses","batches","for","both","masked","language","modeling","and","sentence","order","prediction"]
code: def __call__(self, examples: List[Dict[str, Any]]) -> Dict[str, Any]:
      import torch
      from torch.nn.utils.rnn import pad_sequence
  
      input_ids = [example["input_ids"] for example in examples]
      input_ids = _torch_collate_batch(input_ids, self.tokenizer)
      input_ids, labels, attention_mask = self.mask_tokens(input_ids)
  
      token_type_ids = [
          example["token_type_ids"] for example in examples
      ]
      # size of segment_ids varied because randomness, padding zero to the end as the original implementation
      token_type_ids = pad_sequence(
          token_type_ids,
          batch_first=True,
          padding_value=self.tokenizer.pad_token_id,
      )
  
      sop_label_list = [
          example["sentence_order_label"] for example in examples
      ]
      sentence_order_label = torch.stack(sop_label_list)
  
      return {
          "input_ids": input_ids,
          "labels": labels,
          "attention_mask": attention_mask,
          "token_type_ids": token_type_ids,
          "sentence_order_label": sentence_order_label,
      }
  
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 2 for calling the DataCollatorForSOP obj's underlying member method code with example usage: obj.__call__(examples) and returns: dict