code: def do_apply(self, content, bufs, msg_id, reply_metadata):
      from .serialize import serialize_object, unpack_apply_message
  
      shell = self.shell
      try:
          working = shell.user_ns
  
          prefix = "_" + str(msg_id).replace("-", "") + "_"
  
          f, args, kwargs = unpack_apply_message(
              bufs, working, copy=False
          )
  
          fname = getattr(f, "__name__", "f")
  
          fname = prefix + "f"
          argname = prefix + "args"
          kwargname = prefix + "kwargs"
          resultname = prefix + "result"
  
          ns = {
              fname: f,
              argname: args,
              kwargname: kwargs,
              resultname: None,
          }
          # print ns
          working.update(ns)
          code = "%s = %s(*%s,**%s)" % (
              resultname,
              fname,
              argname,
              kwargname,
          )
          try:
              exec(code, shell.user_global_ns, shell.user_ns)
              result = working.get(resultname)
          finally:
              for key in ns:
                  working.pop(key)
  
          result_buf = serialize_object(
              result,
              buffer_threshold=self.session.buffer_threshold,
              item_threshold=self.session.item_threshold,
          )
  
      except BaseException as e:
          # invoke IPython traceback formatting
          shell.showtraceback()
          reply_content = {
              "traceback": shell._last_traceback or [],
              "ename": unicode_type(type(e).__name__),
              "evalue": safe_unicode(e),
          }
          # FIXME: deprecated piece for ipyparallel (remove in 5.0):
          e_info = dict(
              engine_uuid=self.ident,
              engine_id=self.int_id,
              method="apply",
          )
          reply_content["engine_info"] = e_info
  
          self.send_response(
              self.iopub_socket,
              "error",
              reply_content,
              ident=self._topic("error"),
          )
          self.log.info(
              "Exception in apply request:\n%s",
              "\n".join(reply_content["traceback"]),
          )
          result_buf = []
          reply_content["status"] = "error"
      else:
          reply_content = {"status": "ok"}
  
      return reply_content, result_buf
  
imports: import getpass
  import sys
  from IPython.core import release
  from ipython_genutils.py3compat import builtin_mod, PY3, unicode_type, safe_unicode
  from IPython.utils.tokenutil import token_at_cursor, line_at_cursor
  from traitlets import Instance, Type, Any, List, Bool
  from .comm import CommManager
  from .kernelbase import Kernel
  from .zmqshell import ZMQInteractiveShell
label_desc: Use image node_id 20 for calling the IPythonKernel obj's underlying member method code with example usage: obj.do_apply(content, bufs, msg_id, reply_metadata) and returns: reply_content,  result_buf