class_docstr: Data attributes manage sample-wise information such as task or
  class labels.
  
  It provides access to unique values (`self.uniques`) and their indices
  (`self.val_to_idx`). Both fields are initialized lazily.
  
  Data attributes can be efficiently concatenated and subsampled.
class_docstr_tok: ["Data","attributes","manage","sample-wise","information","such","as","task","or","class","labels",".","It","provides","access","to","unique","values","(","`","self.uniques","`",")","and","their","indices","(","`","self.val_to_idx","`",")",".","Both","fields","are","initialized","lazily",".","Data","attributes","can","be","efficiently","concatenated","and","subsampled","."]
docstr: Dictionary mapping unique values to indices.
docstr_tok: ["Dictionary","mapping","unique","values","to","indices","."]
code: def val_to_idx(self):
      """Dictionary mapping unique values to indices."""
      if self._val_to_idx is None:
          # init. val-to-idx
          self._val_to_idx = dict()
          if isinstance(self.data, ConstantSequence):
              self._val_to_idx = {self.data[0]: range(len(self.data))}
          else:
              for i, x in enumerate(self.data):
                  if x not in self.val_to_idx:
                      self._val_to_idx[x] = []
                  self._val_to_idx[x].append(i)  # type: ignore
      return self._val_to_idx
  
imports: from typing import Dict, List, Optional, Sequence, Set, TypeVar, Union, overload
  import torch
  from .dataset_definitions import IDataset
  from .flat_data import ConstantSequence, FlatData
label_desc: Use image node_id 12 for calling the DataAttribute obj's underlying member method code with example usage: obj.val_to_idx() and returns: self