code: def pytest_sessionstart(session: Session) -> None:
      """Create a temporary directory for the BentoML home directory, then monkey patch to config."""
      from bentoml._internal.utils import analytics
  
      # We need to clear analytics cache before running tests.
      analytics.usage_stats.do_not_track.cache_clear()
      analytics.usage_stats._usage_event_debugging.cache_clear()  # type: ignore (private warning)
  
      mp = MonkeyPatch()
      config = session.config
      config.add_cleanup(mp.undo)
  
      (
          _PYTEST_BENTOML_HOME,
          _PYTEST_MULTIPROC_DIR,
      ) = _setup_test_directory()
  
      # The evironment variable patch ensures that we will
      # always build bento using bentoml from source, use the correct
      # test bentoml home directory, and setup prometheus multiproc directory.
      _setup_session_environment(
          mp,
          session,
          ("PROMETHEUS_MULTIPROC_DIR", _PYTEST_MULTIPROC_DIR),
          ("BENTOML_BUNDLE_LOCAL_BUILD", "True"),
          ("SETUPTOOLS_USE_DISTUTILS", "stdlib"),
          ("__BENTOML_DEBUG_USAGE", "False"),
          ("BENTOML_DO_NOT_TRACK", "True"),
      )
  
      _setup_session_environment(
          mp, config, ("BENTOML_HOME", _PYTEST_BENTOML_HOME)
      )
  
imports: from __future__ import annotations
  import contextlib
  import os
  import tempfile
  import typing
  from typing import TYPE_CHECKING
  import psutil
  import pytest
  from pytest import MonkeyPatch
  import bentoml
  from bentoml._internal.configuration import BENTOML_VERSION
  from bentoml._internal.configuration import clean_bentoml_version
  from bentoml._internal.configuration.containers import BentoMLContainer
  from bentoml._internal.models import ModelContext
  from bentoml._internal.utils import LazyLoader
  from bentoml._internal.utils import validate_or_create_dir
label_desc: Use image node_id 10 for calling a global function with example usage: pytest_sessionstart(session) without return types