class_docstr: A polytope sampler using Delaunay triangulation.
  
  This sampler first enumerates the vertices of the constraint polytope and
  then uses a Delaunay triangulation to tesselate its convex hull.
  
  The sampling happens in two stages:
  1. First, we sample from the set of hypertriangles generated by the
  Delaunay triangulation (i.e. which hyper-triangle to draw the sample
  from) with probabilities proportional to the triangle volumes.
  2. Then, we sample uniformly from the chosen hypertriangle by sampling
  uniformly from the unit simplex of the appropriate dimension, and
  then computing the convex combination of the vertices of the
  hypertriangle according to that draw from the simplex.
  
  The best reference (not exactly the same, but functionally equivalent) is
  [Trikalinos2014polytope]_. A simple R implementation is available at
  https://github.com/gertvv/tesselample.
class_docstr_tok: ["A","polytope","sampler","using","Delaunay","triangulation",".","This","sampler","first","enumerates","the","vertices","of","the","constraint","polytope","and","then","uses","a","Delaunay","triangulation","to","tesselate","its","convex","hull",".","The","sampling","happens","in","two","stages",":","1",".","First",",","we","sample","from","the","set","of","hypertriangles","generated","by","the","Delaunay","triangulation","(","i.e",".","which","hyper-triangle","to","draw","the","sample","from",")","with","probabilities","proportional","to","the","triangle","volumes",".","2",".","Then",",","we","sample","uniformly","from","the","chosen","hypertriangle","by","sampling","uniformly","from","the","unit","simplex","of","the","appropriate","dimension",",","and","then","computing","the","convex","combination","of","the","vertices","of","the","hypertriangle","according","to","that","draw","from","the","simplex",".","The","best","reference","(","not","exactly","the","same",",","but","functionally","equivalent",")","is","[","Trikalinos2014polytope","]","_",".","A","simple","R","implementation","is","available","at","https",":","\/\/github.com\/gertvv\/tesselample","."]
docstr: Draw samples from the polytope.
  
  Args:
      n: The number of samples.
      seed: The random seed.
  
  Returns:
      A `n x d` Tensor of samples from the polytope.
docstr_tok: ["Draw","samples","from","the","polytope",".","Args",":","n",":","The","number","of","samples",".","seed",":","The","random","seed",".","Returns",":","A","`","n","x","d","`","Tensor","of","samples","from","the","polytope","."]
code: def draw(self, n: int = 1, seed: Optional[int] = None) -> Tensor:
      r"""Draw samples from the polytope.
  
      Args:
          n: The number of samples.
          seed: The random seed.
  
      Returns:
          A `n x d` Tensor of samples from the polytope.
      """
      if self.dim == 1:
          with manual_seed(seed):
              e = torch.rand(
                  n, 1, device=self.new_A.device, dtype=self.new_A.dtype
              )
          transformed_samples = (
              self.y_min + (self.y_max - self.y_min) * e
          )
      else:
          if seed is None:
              generator = None
          else:
              generator = torch.Generator(device=self.A.device)
              generator.manual_seed(seed)
          index_rvs = torch.multinomial(
              self._p,
              num_samples=n,
              replacement=True,
              generator=generator,
          )
          simplex_rvs = sample_simplex(
              d=self.dim + 1,
              n=n,
              seed=seed,
              device=self.A.device,
              dtype=self.A.dtype,
          )
          transformed_samples = torch.stack(
              [
                  rv @ self._polytopes[idx]
                  for rv, idx in zip(simplex_rvs, index_rvs)
              ]
          )
      init_shift = self.x0.transpose(-1, -2)
      samples = init_shift + transformed_samples @ self.nullC.transpose(
          -1, -2
      )
      return samples
  
imports: from __future__ import annotations
  from abc import ABC, abstractmethod
  from contextlib import contextmanager
  from typing import Any, Generator, Iterable, List, Optional, Tuple, TYPE_CHECKING
  import numpy
  import scipy
  import torch
  from botorch.exceptions.errors import BotorchError
  from botorch.sampling.qmc import NormalQMCEngine
  from botorch.utils.transforms import unnormalize
  from scipy.spatial import Delaunay, HalfspaceIntersection
  from torch import LongTensor, Tensor
  from torch.quasirandom import SobolEngine
label_desc: Use image node_id 2 for calling the DelaunayPolytopeSampler obj's underlying member method code with example usage: obj.draw(n, seed) and returns: samples