code: def compute_adaptivepool_flops(module, input, output):
      # credits: https://github.com/xternalz/SDPoint/blob/master/utils/flops.py
      batch_size = input.size(0)
      input_planes = input.size(1)
      input_height = input.size(2)
      input_width = input.size(3)
  
      flops = 0
      for i in range(output.size(2)):
          y_start = int(
              math.floor(float(i * input_height) / output.size(2))
          )
          y_end = int(
              math.ceil(float((i + 1) * input_height) / output.size(2))
          )
          for j in range(output.size(3)):
              x_start = int(
                  math.floor(float(j * input_width) / output.size(3))
              )
              x_end = int(
                  math.ceil(
                      float((j + 1) * input_width) / output.size(3)
                  )
              )
  
              flops += (
                  batch_size
                  * input_planes
                  * (y_end - y_start + 1)
                  * (x_end - x_start + 1)
              )
      return flops
  
file_path: tensorwatch/tensorwatch/model_graph/torchstat/compute_flops.py
imports: import torch.nn
  import torch
  import numpy
  import math
label_desc: Use image node_id 3 for calling a global function with example usage: compute_adaptivepool_flops(module, input, output) and returns: flops