code: def ewise_flop_counter(
      input_scale: float = 1, output_scale: float = 0
  ) -> Callable:
      """
      Count flops by
          input_tensor.numel() * input_scale + output_tensor.numel() * output_scale
      Args:
          input_scale: scale of the input tensor (first argument)
          output_scale: scale of the output tensor (first element in outputs)
      """
  
      def ewise_flop(inputs: List[Any], outputs: List[Any]) -> Number:
          ret = 0
          if input_scale != 0:
              shape = inputs[0].shape
              ret += (
                  input_scale * reduce(operator.mul, shape)
                  if shape
                  else 0
              )
          if output_scale != 0:
              shape = outputs[0].shape
              ret += (
                  output_scale * reduce(operator.mul, shape)
                  if shape
                  else 0
              )
          return ret
  
      return ewise_flop
  
imports: import operator
  from collections import defaultdict
  from contextlib import contextmanager
  from enum import Enum, auto
  from functools import partial, reduce
  from numbers import Number
  from typing import Any, Callable, List, Union
  import torch
  from packaging import version
  from torch.utils._pytree import tree_map
  from .meta_tensor import MetaTensor
label_desc: Use image node_id 14 for calling a global function with example usage: ewise_flop_counter(input_scale, output_scale) and returns: ewise_flop, ret