class_docstr: PyTorch dataset class for storing tokenized sentences and other properties used for BERT score calculation.
class_docstr_tok: ["PyTorch","dataset","class","for","storing","tokenized","sentences","and","other","properties","used","for","BERT","score","calculation","."]
docstr: Get the input ids and attention mask belonging to a specific datapoint.
docstr_tok: ["Get","the","input","ids","and","attention","mask","belonging","to","a","specific","datapoint","."]
code: def __getitem__(self, idx: int) -> Dict[str, Tensor]:
      """Get the input ids and attention mask belonging to a specific datapoint."""
      input_ids = self.text["input_ids"][idx, :]
      attention_mask = self.text["attention_mask"][idx, :]
      inputs_dict = {
          "input_ids": input_ids,
          "attention_mask": attention_mask,
      }
      if self.idf:
          input_ids_idf = torch.tensor(
              [
                  self.tokens_idf[input_idx]
                  for input_idx in input_ids.tolist()
              ]
          )
          inputs_dict["input_ids_idf"] = input_ids_idf
      return inputs_dict
  
imports: import math
  import os
  from collections import Counter, defaultdict
  from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Set, Tuple, Union
  import torch
  from torch import Tensor
  from torch.utils.data import DataLoader, Dataset
  from torchmetrics.utilities.data import _cumsum
  from torchmetrics.utilities.imports import _TQDM_AVAILABLE, _TRANSFORMERS_GREATER_EQUAL_4_4
label_desc: Use image node_id 2 for calling the TextDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: inputs_dict