code: def _get_context():
      """Determine the most specific context that we're in.
  
      Returns:
          one of
  
          -   ``_COLAB``: we're in Colab with an IPython notebook context
          -   ``_DATABRICKS``: we're in Databricks with an IPython notebook context
          -   ``_IPYTHON``: we're in an IPython notebook context
              (e.g., from running `jupyter notebook` at the command line)
          -   ``_NONE``: we're in a non-notebook context, e.g., a Python script
              or a Python REPL
      """
      global _context
      if _context is not None:
          return _context
  
      if os.environ.get("FIFTYONE_CONTEXT", None):
          _context = os.environ["FIFTYONE_CONTEXT"]
          return _context
  
      # In Colab, the `google.colab` module is available, but the shell returned
      # by `IPython.get_ipython` does not have a `get_trait` method.
      try:
          import google.colab  # noqa: F401
          import IPython
      except ImportError:
          pass
      else:
          if IPython.get_ipython() is not None:
              # We'll assume that we're in a Colab notebook context.
              _context = _COLAB
              os.environ["FIFTYONE_CONTEXT"] = _context
              return _context
  
      # In Databricks, the `dbutils` module is available and required for the proxy,
      # but the shell returned by `IPython.get_ipython` does not return a kernel
      # via the `get_trait` method.
      try:
          # Location: /databricks/python_shell/dbruntime
          import IPython
          from dbruntime.dbutils import DBUtils  # noqa: F401
      except ImportError:
          pass
      else:
          if IPython.get_ipython() is not None:
              # We'll assume that we're in a Databricks notebook context.
              _context = _DATABRICKS
              os.environ["FIFTYONE_CONTEXT"] = _context
              return _context
  
      # In an IPython command line shell or Jupyter notebook, we can directly
      # query whether we're in a notebook context.
      try:
          import IPython
      except ImportError:
          pass
      else:
          ipython = IPython.get_ipython()
          if ipython is not None and ipython.has_trait("kernel"):
              _context = _IPYTHON
              os.environ["FIFTYONE_CONTEXT"] = _context
              return _context
  
      # Otherwise, we're not in a known notebook context.
      _context = _NONE
      os.environ["FIFTYONE_CONTEXT"] = _context
  
      return _context
  
file_path: fiftyone/fiftyone/core/context.py
imports: import json
  import os
  import typing
  from urllib.parse import urlparse
label_desc: Use image node_id 6 for calling a global function with example usage: _get_context() and returns: _context, _context, _context, _context, _context, _context