code: def test_state(path=None):
      ds = Dataset.create(path)
      sub = ds.create("sub")
      assert_result_count(
          ds.subdatasets(), 1, path=sub.path, state="present"
      )
      # uninstall the subdataset
      ds.drop("sub", what="all", reckless="kill", recursive=True)
      # normal 'gone' is "absent"
      assert_false(sub.is_installed())
      assert_result_count(
          ds.subdatasets(), 1, path=sub.path, state="absent"
      )
      # with directory totally gone also
      os.rmdir(sub.path)
      assert_result_count(
          ds.subdatasets(), 1, path=sub.path, state="absent"
      )
      # putting dir back, no change
      os.makedirs(sub.path)
      assert_result_count(
          ds.subdatasets(), 1, path=sub.path, state="absent"
      )
  
file_path: datalad/datalad/local/tests/test_subdataset.py
imports: import os
  from os.path import join
  from os.path import pardir, relpath
  from datalad.api import clone, create, subdatasets
  from datalad.distribution.dataset import Dataset
  from datalad.tests.utils_pytest import assert_false, assert_in, assert_not_in, assert_repo_status, assert_result_count, assert_status, assert_true, eq_, slow, with_tempfile
  from datalad.utils import Path, PurePosixPath, chpwd
label_desc: Use image node_id 3 for calling a global function with example usage: test_state(path) without return types