code: def memory_efficient_fusion(
      fn: Union[Callable, nn.Module],
      **kwargs,
  ):
      """
      Wrapper function over :func:`aot_function` and :func:`aot_module` to perform
      memory efficient fusion. It uses the
      :func:`min_cut_rematerialization_partition` partitioner to perform efficient
      recomputation. It uses NVFuser to compile the generated forward and backward
      graphs.
  
      .. warning::
          This API is experimental and likely to change.
  
      Args:
          fn (Union[Callable, nn.Module]): A Python function or a ``nn.Module``
              that takes one ore more arguments. Must return one or more Tensors.
          **kwargs: Any other overrides you want to make to the settings
  
      Returns:
          Returns a ``Callable``  or ``nn.Module`` that retains the eager behavior
          of the original :attr:`fn`, but whose forward and backward graphs have
          gone through recomputation optimizations, and the graphs have been
          compiled with nvfuser.
  
      """
      config = {
          "fw_compiler": ts_compile,
          "bw_compiler": ts_compile,
          "partition_fn": min_cut_rematerialization_partition,
          "decompositions": default_decompositions,
      }
      config.update(kwargs)
      if isinstance(fn, torch.nn.Module):
          return aot_module(fn, **config)
      else:
          return aot_function(fn, **config)
  
imports: import copy
  import logging
  import os
  import pickle
  import random
  from contextlib import contextmanager
  from functools import partial
  from typing import Callable, Union
  import sympy
  import torch
  from torch import SymInt
  import torch.fx
  import torch.nn
  from torch._decomp import get_decompositions
  from torch.fx.experimental.symbolic_shapes import bind_symbols
  from .aot_autograd import aot_function, aot_module, make_boxed_compiler
  from .compile_utils import strip_overloads
  from .partitioners import default_partition, draw_graph, min_cut_rematerialization_partition
  import torch.utils._pytree
label_desc: Use image node_id 11 for calling a global function with example usage: memory_efficient_fusion(fn) and returns: aot_module, aot_function