code: def get_draws_stan3(
      fit,
      model=None,
      variables=None,
      ignore=None,
      warmup=False,
      dtypes=None,
  ):
      """Extract draws from PyStan3 fit."""
      if ignore is None:
          ignore = []
  
      if dtypes is None:
          dtypes = {}
  
      if model is not None:
          dtypes = {**infer_dtypes(fit, model), **dtypes}
  
      if not fit.save_warmup:
          warmup = False
  
      num_warmup = ceil(
          (fit.num_warmup * fit.save_warmup) / fit.num_thin
      )
  
      if variables is None:
          variables = fit.param_names
      elif isinstance(variables, str):
          variables = [variables]
      variables = list(variables)
  
      data = OrderedDict()
      data_warmup = OrderedDict()
  
      for var in variables:
          if var in ignore:
              continue
          if var in data:
              continue
          dtype = dtypes.get(var)
  
          new_shape = (
              *fit.dims[fit.param_names.index(var)],
              -1,
              fit.num_chains,
          )
          if 0 in new_shape:
              continue
          values = fit._draws[
              fit._parameter_indexes(var), :
          ]  # pylint: disable=protected-access
          values = values.reshape(new_shape, order="F")
          values = np.moveaxis(values, [-2, -1], [1, 0])
          values = values.astype(dtype)
          if warmup:
              data_warmup[var] = values[:, num_warmup:]
          data[var] = values[:, num_warmup:]
  
      return data, data_warmup
  
imports: import re
  from collections import OrderedDict
  from copy import deepcopy
  from math import ceil
  import numpy
  import xarray
  from ..None import _log
  from ..rcparams import rcParams
  from .base import dict_to_dataset, generate_dims_coords, infer_stan_dtypes, make_attrs, requires
  from .inference_data import InferenceData
label_desc: Use image node_id 4 for calling a global function with example usage: get_draws_stan3(fit, model, variables, ignore, warmup, dtypes) and returns: data,  data_warmup