code: def fake_pip(version=ensurepip.version()):
      if version is None:
          pip = None
      else:
  
          class FakePip:
              __version__ = version
  
          pip = FakePip()
      sentinel = object()
      orig_pip = sys.modules.get("pip", sentinel)
      sys.modules["pip"] = pip
      try:
          yield pip
      finally:
          if orig_pip is sentinel:
              del sys.modules["pip"]
          else:
              sys.modules["pip"] = orig_pip
  
imports: import contextlib
  import os
  import os.path
  import sys
  import tempfile
  import test.support
  import unittest
  import unittest.mock
  import ensurepip
  import ensurepip._uninstall
label_desc: Use image node_id 1 for calling a global function with example usage: fake_pip(version) without return types