code: def require_mode(mode):
      def wrapper(f):
          @wraps(f)
          def method(self, *args, **kwargs):
              if mode is not None and self._mode != mode:
                  raise MetaflowInternalError(
                      "Attempting a datastore operation '%s' requiring mode '%s' "
                      "but have mode '%s'"
                      % (f.__name__, mode, self._mode)
                  )
              return f(self, *args, **kwargs)
  
          return method
  
      return wrapper
  
imports: from collections import defaultdict
  import json
  import pickle
  import sys
  import time
  from functools import wraps
  from io import BufferedIOBase, FileIO, RawIOBase
  from types import MethodType, FunctionType
  from ..None import metaflow_config
  from ..exception import MetaflowInternalError
  from ..metadata import DataArtifact, MetaDatum
  from ..parameters import Parameter
  from ..util import Path, is_stringish, to_fileobj
  from .exceptions import DataException, UnpicklableArtifactException
label_desc: Use image node_id 2 for calling a global function with example usage: require_mode(mode) and returns: wrapper, method, f