code: def profile_function(target: "Target") -> Callable:
      """
      Wrap a `call_function` node or `torch.nn.functional` in order to
      record the memory cost and FLOPs of the execution.
      Unfortunately, backward memory cost and FLOPs are estimated results.
  
      Warnings:
          You may only use tensors with `device=meta` for this wrapped function.
          Only original `torch.nn.functional` are available.
  
      Examples:
          >>> input = torch.rand(100, 100, 100, 100, device='meta')
          >>> func = torch.nn.functional.relu
          >>> output, (fwd_flop, bwd_flop), (fwd_tmp, fwd_out, bwd_tmp, bwd_out) = profile_function(func)(input, inplace=False)
      """
  
      def f(
          *args: Tuple[Argument, ...], **kwargs: Dict[str, Any]
      ) -> Any:
          assert meta_profiler_function.has(
              target
          ) or meta_profiler_function.has(
              target.__name__
          ), CALL_FUNCTION_MSG.format(
              target
          )
  
          fwd_tmp = 0
          fwd_out = 0
          out = func(*args, **kwargs)
          if target not in INPLACE_OPS and not kwargs.get(
              "inplace", False
          ):
              fwd_out = activation_size(out)
          if meta_profiler_function.has(target):
              profiler = meta_profiler_function.get(target)
          else:
              profiler = meta_profiler_function.get(target.__name__)
          fwd_flop, _ = profiler(*args, **kwargs)
          return out, GraphInfo(
              fwd_flop,
              fwd_flop * 2,
              fwd_tmp,
              fwd_out,
              fwd_tmp + fwd_out,
              0,
          )
  
      f.__name__ = target.__name__
      func = target
      return f
  
file_path: ColossalAI/colossalai/fx/profiler/experimental/profiler.py
imports: from dataclasses import dataclass
  from typing import Any, Callable, Dict, Tuple
  import torch
  from torch.fx.node import Argument, Target
  from ..._compatibility import compatibility
  from ..memory_utils import activation_size
  from .constants import INPLACE_METHOD, INPLACE_OPS, NON_INPLACE_METHOD
  from .registry import meta_profiler_function, meta_profiler_module
label_desc: Use image node_id 1 for calling a global function with example usage: profile_function(target) and returns: f, out,  GraphInfo