code: def test_pickle_functions(protocol):
      context = {"pickle-protocol": protocol}
  
      def make_closure():
          value = 1
  
          def f(x):  # closure
              return x + value
  
          return f
  
      def funcs():
          yield make_closure()
          yield (lambda x: x + 1)
          yield partial(add, 1)
  
      for func in funcs():
          wr = weakref.ref(func)
  
          func2 = loads(dumps(func, protocol=protocol))
          wr2 = weakref.ref(func2)
          assert func2(1) == func(1)
  
          func3 = deserialize(
              *serialize(func, serializers=("pickle",), context=context)
          )
          wr3 = weakref.ref(func3)
          assert func3(1) == func(1)
  
          del func, func2, func3
          with profile.lock:
              assert wr() is None
              assert wr2() is None
              assert wr3() is None
  
imports: from __future__ import annotations
  import pickle
  import sys
  import weakref
  from functools import partial
  from operator import add
  import cloudpickle
  import pytest
  from dask.utils import tmpdir
  from distributed import profile
  from distributed.protocol import deserialize, serialize
  from distributed.protocol.pickle import CLOUDPICKLE_GE_20, HIGHEST_PROTOCOL, dumps, loads
  from distributed.protocol.serialize import dask_deserialize, dask_serialize
  from distributed.utils_test import popen, save_sys_modules
label_desc: Use image node_id 5 for calling a global function with example usage: test_pickle_functions(protocol) and returns: f, unknown