code: def get_pure_function(fcn) -> PureFunction:
      """Get the pure function form of the function or method ``fcn``.
  
      Examples
      --------
      >>> import torch
      >>> from deepchem.utils.differentiation_utils import get_pure_function
      >>> def fcn(x, y):
      ...     return x + y
      >>> pfunc = get_pure_function(fcn)
      >>> pfunc(1, 2)
      3
  
      Parameters
      ----------
      fcn: function or method
          Function or method to be converted into a ``PureFunction`` by exposing
          the hidden parameters affecting its outputs.
  
      Returns
      -------
      PureFunction
          The pure function wrapper
  
      """
  
      errmsg = (
          "The input function must be a function, a method of "
          "torch.nn.Module, a method of xitorch.EditableModule, or a sibling method"
      )
  
      if isinstance(fcn, PureFunction):
          return fcn
  
      elif inspect.isfunction(fcn) or isinstance(
          fcn, torch.jit.ScriptFunction
      ):
          return FunctionPureFunction(fcn)
  
      # if it is a method from an object, unroll the parameters and add
      # the object's parameters as well
      elif inspect.ismethod(fcn) or hasattr(fcn, "__call__"):
          if inspect.ismethod(fcn):
              obj = fcn.__self__
          else:
              obj = fcn
              fcn = fcn.__call__
  
          if isinstance(obj, EditableModule):
              return EditableModulePureFunction(obj, fcn)
          elif isinstance(obj, torch.nn.Module):
              return TorchNNPureFunction(obj, fcn)
          else:
              raise RuntimeError(errmsg)
  
      else:
          raise RuntimeError(errmsg)
  
imports: import torch
  import inspect
  from typing import Callable, List, Tuple, Union
  from deepchem.utils.attribute_utils import set_attr, del_attr
  from deepchem.utils.differentiation_utils import EditableModule
  from deepchem.utils.misc_utils import Uniquifier
  from contextlib import contextmanager
  from abc import abstractmethod
label_desc: Use image node_id 2 for calling a global function with example usage: get_pure_function(fcn) and returns: fcn, FunctionPureFunction, EditableModulePureFunction, TorchNNPureFunction