code: def _proc_dataset(
      refds,
      ds,
      site,
      project,
      remotename,
      layout,
      existing,
      access,
      dry_run,
      siteobjs,
      depends,
      description,
  ):
      # basic result setup
      res_kwargs = dict(
          action="create_sibling_gitlab",
          refds=refds.path,
          path=ds.path,
          type="dataset",
          logger=lgr,
      )
      if description:
          res_kwargs["description"] = description
  
      if site is None:
          # always try pulling the base config from a parent dataset
          # even if paths were given (may be overwritten later)
          basecfgsite = ds.config.get(
              "datalad.gitlab-default-site", None
          )
  
      # let the dataset config overwrite the target site, if none
      # was given
      site = (
          refds.config.get("datalad.gitlab-default-site", basecfgsite)
          if site is None
          else site
      )
      if site is None:
          # this means the most top-level dataset has no idea about
          # gitlab, and no site was specified as an argument
          # fail rather then give an error result, as this is very
          # unlikely to be intentional
          raise ValueError(
              "No GitLab site was specified (--site) or configured "
              "in {} (datalad.gitlab.default-site)".format(ds)
          )
      res_kwargs["site"] = site
  
      # determine target remote name, unless given
      if remotename is None:
          remotename_var = "datalad.gitlab-{}-siblingname".format(site)
          remotename = ds.config.get(
              remotename_var,
              # use config from parent, if needed
              refds.config.get(
                  remotename_var,
                  # fall back on site name, if nothing else can be used
                  site,
              ),
          )
      res_kwargs["sibling"] = remotename
      # check against existing remotes
      dremotes = {
          r["name"]: r
          for r in ds.siblings(
              action="query",
              # fastest possible
              get_annex_info=False,
              recursive=False,
              return_type="generator",
              result_renderer="disabled",
          )
      }
      if remotename in dremotes and existing not in [
          "replace",
          "reconfigure",
      ]:
          # we already know a sibling with this name
          yield dict(
              res_kwargs,
              status="error" if existing == "error" else "notneeded",
              message=(
                  'already has a configured sibling "%s"',
                  remotename,
              ),
          )
          return
  
      if layout is None:
          # figure out the layout of projects on the site
          # use the reference dataset as default, and fall back
          # on 'collection' as the most generic method of representing
          # the filesystem in a group/subproject structure
          layout_var = "datalad.gitlab-{}-layout".format(site)
          layout = ds.config.get(
              layout_var, refds.config.get(layout_var, "collection")
          )
      if layout not in known_layout_labels:
          raise ValueError(
              "Unknown site layout '{}' given or configured, "
              "known ones are: {}".format(layout, known_layout_labels)
          )
  
      if access is None:
          access_var = "datalad.gitlab-{}-access".format(site)
          access = ds.config.get(
              access_var, refds.config.get(access_var, "http")
          )
      if access not in known_access_labels:
          raise ValueError(
              "Unknown site access '{}' given or configured, "
              "known ones are: {}".format(access, known_access_labels)
          )
  
      pathsep = ds.config.get(
          "datalad.gitlab-default-pathseparator", "-"
      )
      project_stub = ds.config.get(
          "datalad.gitlab-default-projectname", "project"
      )
      project_var = "datalad.gitlab-{}-project".format(site)
      process_root = refds == ds
      if project is None:
          # look for a specific config in the dataset
          project = ds.config.get(project_var, None)
  
      if project and process_root and layout != "flat":
          # the root of a collection
          project = f"{project}/{project_stub}"
      elif project is None and not process_root:
          # check if we can build one from the refds config
          ref_project = refds.config.get(project_var, None)
          if ref_project:
              # layout-specific derivation of a path from
              # the reference dataset configuration
              rproject = ds.pathobj.relative_to(
                  refds.pathobj
              ).as_posix()
              if layout == "collection":
                  project = "{}/{}".format(
                      ref_project, rproject.replace("/", pathsep)
                  )
              else:
                  project = "{}{}{}".format(
                      ref_project,
                      pathsep,
                      rproject.replace("/", pathsep),
                  )
  
      if project is None:
          yield dict(
              res_kwargs,
              status="error",
              message="No project name/location specified, and no configuration "
              "to derive one",
          )
          return
  
      res_kwargs["project"] = project
  
      if dry_run:
          # this is as far as we can get without talking to GitLab
          yield dict(
              res_kwargs,
              status="ok",
              dryrun=True,
          )
          return
  
      # and now talk to GitLab for real
      site_api = (
          siteobjs[site] if site in siteobjs else GitLabSite(site)
      )
  
      site_project = site_api.get_project(project)
      if site_project is None:
          try:
              site_project = site_api.create_project(
                  project, description
              )
              # report success
              message = (
                  "sibling repository '%s' created at %s",
                  remotename,
                  site_project.get("web_url", None),
              )
              yield dict(
                  res_kwargs,
                  # relay all attributes
                  project_attributes=site_project,
                  message=message,
                  status="ok",
              )
          except Exception as e:
              ce = CapturedException(e)
              yield dict(
                  res_kwargs,
                  # relay all attributes
                  status="error",
                  message=("Failed to create GitLab project: %s", ce),
                  exception=ce,
              )
              return
      else:
          # there already is a project
          if existing == "error":
              # be nice and only actually error if there is a real mismatch
              if remotename not in dremotes:
                  yield dict(
                      res_kwargs,
                      project_attributes=site_project,
                      status="error",
                      message=(
                          "There is already a project at '%s' on site '%s', "
                          "but no sibling with name '%s' is configured, "
                          "maybe use --existing=reconfigure",
                          project,
                          site,
                          remotename,
                      ),
                  )
                  return
              elif access in ("ssh", "ssh+http") and dremotes[
                  remotename
              ].get("url", None) != site_project.get(
                  # use False as a default so that there is a
                  # mismatch, complain if both are missing
                  "ssh_url_to_repo",
                  False,
              ):
                  yield dict(
                      res_kwargs,
                      project_attributes=site_project,
                      status="error",
                      message=(
                          "There is already a project at '%s' on site '%s', "
                          "but SSH access URL '%s' does not match '%s', "
                          "maybe use --existing=reconfigure",
                          project,
                          site,
                          dremotes[remotename].get("url", None),
                          site_project.get("ssh_url_to_repo", None),
                      ),
                  )
                  return
              elif access == "http" and dremotes[remotename].get(
                  "url", None
              ) != site_project.get(
                  # use False as a default so that there is a
                  # mismatch, veen if both are missing
                  "http_url_to_repo",
                  False,
              ):
                  yield dict(
                      res_kwargs,
                      project_attributes=site_project,
                      status="error",
                      message=(
                          "There is already a project at '%s' on site '%s', "
                          "but HTTP access URL '%s' does not match '%s', "
                          "maybe use --existing=reconfigure",
                          project,
                          site,
                          dremotes[remotename].get("url", None),
                          site_project.get("http_url_to_repo", None),
                      ),
                  )
                  return
          yield dict(
              res_kwargs,
              project_attributes=site_project,
              status="notneeded",
              message=(
                  "There is already a project at '%s' on site '%s'",
                  project,
                  site,
              ),
          )
  
      # first make sure that annex doesn't touch this one
      # but respect any existing config
      ignore_var = "remote.{}.annex-ignore".format(remotename)
      if ignore_var not in ds.config:
          ds.config.add(ignore_var, "true", scope="local")
  
      for res in ds.siblings(
          "configure",
          name=remotename,
          url=site_project["http_url_to_repo"]
          if access in ("http", "ssh+http")
          else site_project["ssh_url_to_repo"],
          pushurl=site_project["ssh_url_to_repo"]
          if access in ("ssh", "ssh+http")
          else None,
          recursive=False,
          publish_depends=depends,
          result_renderer="disabled",
          return_type="generator",
      ):
          yield res
  
imports: import logging
  import warnings
  from datalad.support.exceptions import CapturedException
  from ..distribution.dataset import EnsureDataset, datasetmethod, require_dataset, resolve_path
  from ..distribution.siblings import Siblings
  from ..dochelpers import exc_str
  from ..interface.base import Interface, build_doc, eval_results
  from ..interface.common_opts import publish_depends, recursion_flag, recursion_limit
  from ..local.subdatasets import Subdatasets
  from ..support.constraints import EnsureChoice, EnsureNone, EnsureStr
  from ..support.param import Parameter
  from ..utils import ensure_list
label_desc: Use image node_id 1 for calling a global function with example usage: _proc_dataset(refds, ds, site, project, remotename, layout, existing, access, dry_run, siteobjs, depends, description) without return types