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: Connects to the database.
  Databases will automatically connect on instantiation.
docstr_tok: ["Connects","to","the","database",".","Databases","will","automatically","connect","on","instantiation","."]
code: def connect(self) -> None:
      r"""Connects to the database.
      Databases will automatically connect on instantiation.
      """
      pass
  
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 2 for calling the Database obj's underlying member method code with example usage: obj.connect() without return types