code: def transform(f) -> Transformed:
      """Transforms a function using Sonnet modules into a pair of pure functions.
  
      The first thing to do is to create some `snt.Module` instances:
  
      >>> with snt.functional.variables():
      ...   a = snt.Linear(10, name="a")
      ...   b = snt.Linear(10, name="b")
  
      Next, define some function that creates and applies modules:
  
      >>> def f(x):
      ...   return a(x) + b(x)
  
      Now we can convert that function into a pair of functions that allow us to
      lift all the parameters out of the function (`f.ini`) and apply the function
      with a given set of parameters (`f.apply`):
  
      >>> f = snt.functional.transform(f)
  
      To get the initial state of the module call `f.init` with an example input:
  
      >>> x = tf.ones([1, 1])
      >>> params = f.init(x)
      >>> params
      {<...>: <tf.Tensor: ...>,
       <...>: <tf.Tensor: ...>,
       <...>: <tf.Tensor: ...>,
       <...>: <tf.Tensor: ...>}
  
      You can then apply the function with the given parameters by calling
      `f.apply`:
  
      >>> f.apply(params, x)
      <tf.Tensor: ...>
  
      It is expected that your program will at some point produce updated parameters
      and you will want to re-apply `f.apply`. You can do this by calling
      `f.apply` with different parameters:
  
      >>> new_params = tree.map_structure(lambda p: p + 1, params)
      >>> f.apply(new_params, x)
      <tf.Tensor: ...>
  
      If your network contains non-trainable state (e.g. moving averages) then you
      will need to use :func:`transform_with_state`.
  
      Args:
        f: A function closing over `Module` instances.
  
      Returns:
        A transformed function with `init` and `apply`. See docstring for details.
      """
      return without_state(transform_with_state(f))
  
imports: import collections
  import functools
  import itertools
  import threading
  import contextlib
  from sonnet.src.functional import utils
  import tensorflow
label_desc: Use image node_id 15 for calling a global function with example usage: transform(f) and returns: without_state