class_docstr: Base class for inserting and retrieving data from a database.
  
  A database acts as a persisted, out-of-memory and index-based key/value
  store for tensor and custom data:
  
  .. code-block:: python
  
      db = Database()
      db[0] = Data(x=torch.randn(5, 16), y=0, z='id_0')
      print(db[0])
      >>> Data(x=[5, 16], y=0, z='id_0')
  
  To improve efficiency, it is recommended to specify the underlying
  :obj:`schema` of the data:
  
  .. code-block:: python
  
      db = Database(schema={  # Custom schema:
          # Tensor information can be specified through a dictionary:
          'x': dict(dtype=torch.float, size=(-1, 16)),
          'y': int,
          'z': str,
      })
      db[0] = dict(x=torch.randn(5, 16), y=0, z='id_0')
      print(db[0])
      >>> {'x': torch.tensor(...), 'y': 0, 'z': 'id_0'}
  
  In addition, databases support batch-wise insert and get, and support
  syntactic sugar known from indexing :python:`Python` lists, *e.g.*:
  
  .. code-block:: python
  
      db = Database()
      db[2:5] = torch.randn(3, 16)
      print(db[torch.tensor([2, 3])])
      >>> [torch.tensor(...), torch.tensor(...)]
  
  Args:
      schema (Any or Tuple[Any] or Dict[str, Any], optional): The schema of
          the input data.
          Can take :obj:`int`, :obj:`float`, :obj:`str`, :obj:`object`, or a
          dictionary with :obj:`dtype` and :obj:`size` keys (for specifying
          tensor data) as input, and can be nested as a tuple or dictionary.
          Specifying the schema will improve efficiency, since by default the
          database will use python pickling for serializing and
          deserializing. (default: :obj:`object`)
class_docstr_tok: ["Base","class","for","inserting","and","retrieving","data","from","a","database",".","A","database","acts","as","a","persisted",",","out-of-memory","and","index-based","key\/value","store","for","tensor","and","custom","data",":","..","code-block",":",":","python","db","=","Database","(",")","db","[","0","]","=","Data","(","x=torch.randn","(","5",",","16",")",",","y=0",",","z='id_0","'",")","print","(","db","[","0","]",")",">",">",">","Data","(","x=","[","5",",","16","]",",","y=0",",","z='id_0","'",")","To","improve","efficiency",",","it","is","recommended","to","specify","the","underlying",":","obj",":","`","schema","`","of","the","data",":","..","code-block",":",":","python","db","=","Database","(","schema=","{","#","Custom","schema",":","#","Tensor","information","can","be","specified","through","a","dictionary",":","'","x","'",":","dict","(","dtype=torch.float",",","size=","(","-1",",","16",")",")",",","'","y","'",":","int",",","'","z","'",":","str",",","}",")","db","[","0","]","=","dict","(","x=torch.randn","(","5",",","16",")",",","y=0",",","z='id_0","'",")","print","(","db","[","0","]",")",">",">",">","{","'","x","'",":","torch.tensor","(","...",")",",","'","y","'",":","0",",","'","z","'",":","'id_0","'","}","In","addition",",","databases","support","batch-wise","insert","and","get",",","and","support","syntactic","sugar","known","from","indexing",":","python",":","`","Python","`","lists",",","*","e.g",".","*",":","..","code-block",":",":","python","db","=","Database","(",")","db","[","2:5","]","=","torch.randn","(","3",",","16",")","print","(","db","[","torch.tensor","(","[","2",",","3","]",")","]",")",">",">",">","[","torch.tensor","(","...",")",",","torch.tensor","(","...",")","]","Args",":","schema","(","Any","or","Tuple","[","Any","]","or","Dict","[","str",",","Any","]",",","optional",")",":","The","schema","of","the","input","data",".","Can","take",":","obj",":","`","int","`",",",":","obj",":","`","float","`",",",":","obj",":","`","str","`",",",":","obj",":","`","object","`",",","or","a","dictionary","with",":","obj",":","`","dtype","`","and",":","obj",":","`","size","`","keys","(","for","specifying","tensor","data",")","as","input",",","and","can","be","nested","as","a","tuple","or","dictionary",".","Specifying","the","schema","will","improve","efficiency",",","since","by","default","the","database","will","use","python","pickling","for","serializing","and","deserializing",".","(","default",":",":","obj",":","`","object","`",")"]
docstr: Inserts a chunk of data at the specified indices.
  
  Args:
      indices (List[int] or torch.Tensor or range): The indices at which
          to insert.
      data_list (List[Any]): The objects to insert.
      batch_size (int, optional): If specified, will insert the data to
          the database in batches of size :obj:`batch_size`.
          (default: :obj:`None`)
      log (bool, optional): If set to :obj:`True`, will log progress to
          the console. (default: :obj:`False`)
docstr_tok: ["Inserts","a","chunk","of","data","at","the","specified","indices",".","Args",":","indices","(","List","[","int","]","or","torch.Tensor","or","range",")",":","The","indices","at","which","to","insert",".","data_list","(","List","[","Any","]",")",":","The","objects","to","insert",".","batch_size","(","int",",","optional",")",":","If","specified",",","will","insert","the","data","to","the","database","in","batches","of","size",":","obj",":","`","batch_size","`",".","(","default",":",":","obj",":","`","None","`",")","log","(","bool",",","optional",")",":","If","set","to",":","obj",":","`","True","`",",","will","log","progress","to","the","console",".","(","default",":",":","obj",":","`","False","`",")"]
code: def multi_insert(
      self,
      indices: Union[Sequence[int], Tensor, slice, range],
      data_list: Sequence[Any],
      batch_size: Optional[int] = None,
      log: bool = False,
  ) -> None:
      r"""Inserts a chunk of data at the specified indices.
  
      Args:
          indices (List[int] or torch.Tensor or range): The indices at which
              to insert.
          data_list (List[Any]): The objects to insert.
          batch_size (int, optional): If specified, will insert the data to
              the database in batches of size :obj:`batch_size`.
              (default: :obj:`None`)
          log (bool, optional): If set to :obj:`True`, will log progress to
              the console. (default: :obj:`False`)
      """
      if isinstance(indices, slice):
          indices = self.slice_to_range(indices)
  
      length = min(len(indices), len(data_list))
      batch_size = length if batch_size is None else batch_size
  
      if log and length > batch_size:
          desc = f"Insert {length} entries"
          offsets = tqdm(range(0, length, batch_size), desc=desc)
      else:
          offsets = range(0, length, batch_size)
  
      for start in offsets:
          self._multi_insert(
              indices[start : start + batch_size],
              data_list[start : start + batch_size],
          )
  
imports: import pickle
  import warnings
  from abc import ABC, abstractmethod
  from dataclasses import dataclass
  from functools import cached_property
  from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
  from uuid import uuid4
  import torch
  from torch import Tensor
  from tqdm import tqdm
  from torch_geometric import EdgeIndex
  from torch_geometric.edge_index import SortOrder
  from torch_geometric.utils.mixin import CastMixin
label_desc: Use image node_id 5 for calling the Database obj's underlying member method code with example usage: obj.multi_insert(indices, data_list, batch_size, log) without return types