code: def which(cmd, env=None, pathext=None):
      """
      Return the path to an executable which would be run if the given
      cmd was called. If no cmd would be called, return ``None``.
  
      Code for Python < 3.3 is based on a code snippet from
      http://orip.org/2009/08/python-checking-if-executable-exists-in.html
  
      """
  
      if pathext is None:
          pathext = os.getenv("PATHEXT", "").split(os.pathsep)
          pathext.insert(0, "")
  
      path = os.getenv("PATH", os.defpath)
      if env and "PATH" in env:
          path = env.get("PATH")
  
      for ext in pathext:
          filename = shutil.which(cmd + ext, path=path)
          if filename:
              return filename
      return None
  
imports: import sys
  import pickle
  import errno
  import subprocess
  import gzip
  import hashlib
  import locale
  from hashlib import md5
  import os
  import os.path
  import re
  import shutil
  import contextlib
  import posixpath
  from pathlib import Path
  import simplejson
  from time import sleep, time
  from ..None import logging, config, __version__
  from .misc import is_container
label_desc: Use image node_id 30 for calling a global function with example usage: which(cmd, env, pathext) and returns: None, filename