code: def add_examples(
      list_of_examples: list[Example],
      path: str,
      examples_dir: str,
      example_type: int | None = None,
      slow: list[str] | All | None = None,
      skip: list[str] | All | None = None,
      xfail: list[str] | All | None = None,
      no_js: list[str] | All | None = None,
  ) -> None:
      example_pattern = normpath(join(examples_dir, path))
      example_path = normpath(example_pattern.strip("*"))
  
      for path in sorted(iglob(example_pattern, recursive=True)):
          flags = 0
          extensions: list[str] = []
          orig_name = name = str(Path(path).relative_to(example_path))
  
          if name.startswith(("_", ".")):
              continue
          elif name.endswith(".py"):
              flags |= example_type if example_type else Flags.file
          elif name.endswith(".ipynb"):
              flags |= Flags.notebook
          elif isdir(join(example_path, name)):
              if exists(join(example_path, name, name + ".py")):
                  name = join(name, name + ".py")
                  flags |= example_type if example_type else Flags.file
              elif exists(join(example_path, name, "main.py")):
                  # name is unchanged and passed as the example name
                  flags |= (
                      example_type if example_type else Flags.server
                  )
              else:
                  continue
  
              ext_file = "bokeh.ext.json"
              if exists(join(example_path, orig_name, ext_file)):
                  extensions.append(join(example_path, orig_name))
              else:
                  for dir_name in os.listdir(
                      join(example_path, orig_name)
                  ):
                      dir_path = join(example_path, orig_name, dir_name)
                      if exists(join(dir_path, ext_file)):
                          extensions.append(dir_path)
          else:
              continue
  
          if slow is not None and orig_name in slow:
              flags |= Flags.slow
  
          if skip is not None and (
              skip == "all" or basename(orig_name) in skip
          ):
              flags |= Flags.skip
  
          if xfail is not None and (
              xfail == "all" or basename(orig_name) in xfail
          ):
              flags |= Flags.xfail
  
          if no_js is not None and (
              no_js == "all" or basename(orig_name) in no_js
          ):
              flags |= Flags.no_js
  
          list_of_examples.append(
              Example(
                  join(example_path, name),
                  flags,
                  examples_dir,
                  extensions,
              )
          )
  
imports: from __future__ import annotations
  import logging
  import os
  from base64 import b64decode
  from glob import iglob
  from os.path import basename, dirname, exists, isdir, join, normpath, pardir, relpath, splitext
  from pathlib import Path
  from typing import TYPE_CHECKING, Literal, Union
  import yaml
label_desc: Use image node_id 1 for calling a global function with example usage: add_examples(list_of_examples, path, examples_dir, example_type, slow, skip, xfail, no_js) without return types