docs: def sample(net: BayesNet,
             sample_from: Iterable[Vertex],
             sampling_algorithm: PosteriorSamplingAlgorithm = None,
             draws: int = 500,
             drop: int = 0,
             down_sample_interval: int = 1,
             plot: bool = False,
             ax: Any = None) -> sample_types:
      """
      :param net: Bayesian Network containing latent variables.
      :param sample_from: Vertices to include in the returned samples.
      :param sampling_algorithm: The posterior sampling algorithm to use.
          Options are :class:`keanu.algorithm.MetropolisHastingsSampler`, :class:`keanu.algorithm.NUTSSampler` and :class:`keanu.algorithm.ForwardSampler`
          If not set, :class:`keanu.algorithm.MetropolisHastingsSampler` is chosen with 'prior' as its proposal distribution.
      :param draws: The number of samples to take.
      :param drop: The number of samples to drop before collecting anything.
          If this is zero then no samples will be dropped before collecting.
      :param down_sample_interval: Collect 1 sample for every `down_sample_interval`.
          If this is 1 then there will be no down-sampling.
          If this is 2 then every other sample will be taken.
          If this is 3 then 2 samples will be dropped before one is taken.
          And so on.
      :param plot: Flag for plotting the trace after sampling.
          Call `matplotlib.pyplot.show <https://matplotlib.org/api/_as_gen/matplotlib.pyplot.show.html>`_ to display the plot.
      :param Axes ax: `matplotlib.axes.Axes <https://matplotlib.org/api/axes_api.html>`_.
          If not set, a new one is created.
  
      :raises ValueError: If `sample_from` contains vertices without labels.
  
      :return: Dictionary of samples at an index (tuple) for each vertex label (str). If all the vertices in `sample_from` are scalar, the dictionary is only keyed by label.
      """
  
      sample_from = list(sample_from)
      id_to_label = __check_if_vertices_are_labelled(sample_from)
  
      if sampling_algorithm is None:
          sampling_algorithm = MetropolisHastingsSampler(proposal_distribution="prior", latents=sample_from)
  
      vertices_unwrapped: JavaList = k.to_java_object_list(sample_from)
  
      probabilistic_model = ProbabilisticModel(net) if (
          isinstance(sampling_algorithm, MetropolisHastingsSampler) or
          isinstance(sampling_algorithm, ForwardSampler)) else ProbabilisticModelWithGradient(net)
  
      network_samples: JavaObject = sampling_algorithm.get_sampler().getPosteriorSamples(
          probabilistic_model.unwrap(), vertices_unwrapped, draws).drop(drop).downSample(down_sample_interval)
  
      if __all_scalar(sample_from):
          vertex_samples = __create_single_indexed_samples(network_samples, vertices_unwrapped, id_to_label)
      else:
          vertex_samples = __create_multi_indexed_samples(vertices_unwrapped, network_samples, id_to_label)
  
      if plot:
          traceplot(vertex_samples, ax=ax)
  
      return vertex_samples