code: def test_pooling(pooling, padds, backend):
      assert "1d" in pooling.__name__ or "2d" in pooling.__name__
  
      if "2d" in pooling.__name__:
          n_in = 2
          size_in_height = 15
          size_in_width = 18
      else:
          n_in = 2
          size_in_width = 121
          size_in_height = 0
  
      input_shape = (
          (1, n_in, size_in_height, size_in_width)
          if "2d" in pooling.__name__
          else (1, n_in, size_in_width)
      )
      input_shape_forHLS = (
          (None, n_in, size_in_height, size_in_width)
          if "2d" in pooling.__name__
          else (None, n_in, size_in_width)
      )
      X_input = np.random.rand(*input_shape)
  
      model = torch.nn.Sequential(pooling(2, padding=padds)).to()
      model.eval()
      pytorch_prediction = model(torch.Tensor(X_input)).detach().numpy()
  
      config = config_from_pytorch_model(model)
      output_dir = str(
          test_root_path
          / f"hls4mlprj_pytorch_api_pooling_{pooling.__name__}_padds_{padds}_backend_{backend}"
      )
      hls_model = convert_from_pytorch_model(
          model,
          input_shape_forHLS,
          hls_config=config,
          output_dir=output_dir,
          backend=backend,
      )
      hls_model.compile()
  
      from torch.fx import symbolic_trace
  
      traced_model = symbolic_trace(model)
      nNodes = 0
      poolNode = None
      for _node in traced_model.graph.nodes:
          nNodes += 1
          if nNodes == 2:
              poolNode = _node
      assert nNodes + 1 == len(hls_model.get_layers())
      children = {c[0]: c[1] for c in model.named_children()}
      class_object_pool = children[poolNode.target]
  
      if "Max" in pooling.__name__:
          out_height = int(
              math.floor(
                  float(
                      size_in_height
                      + 2 * padds
                      - class_object_pool.dilation
                      * (class_object_pool.kernel_size - 1)
                      - 1
                  )
                  / float(class_object_pool.stride)
                  + 1
              )
          )
          out_width = int(
              math.floor(
                  float(
                      size_in_width
                      + 2 * padds
                      - class_object_pool.dilation
                      * (class_object_pool.kernel_size - 1)
                      - 1
                  )
                  / float(class_object_pool.stride)
                  + 1
              )
          )
      else:
          if "2d" in pooling.__name__:
              out_height = int(
                  math.floor(
                      (
                          size_in_height
                          + 2 * padds
                          - class_object_pool.kernel_size
                      )
                      / class_object_pool.stride
                      + 1
                  )
              )
              out_width = int(
                  math.floor(
                      (
                          size_in_width
                          + 2 * padds
                          - class_object_pool.kernel_size
                      )
                      / class_object_pool.stride
                      + 1
                  )
              )
          else:
              out_height = int(
                  math.floor(
                      (
                          size_in_height
                          + 2 * padds
                          - class_object_pool.kernel_size[0]
                      )
                      / class_object_pool.stride[0]
                      + 1
                  )
              )
              out_width = int(
                  math.floor(
                      (
                          size_in_width
                          + 2 * padds
                          - class_object_pool.kernel_size[0]
                      )
                      / class_object_pool.stride[0]
                      + 1
                  )
              )
  
      if "2d" in pooling.__name__:
          hls_prediction = np.reshape(
              hls_model.predict(X_input),
              (1, n_in, out_height, out_width),
          )
  
      else:
          pred = hls_model.predict(X_input)
          hls_prediction = np.reshape(pred, (1, n_in, out_width))
  
      # results are not very good at the moment
      np.testing.assert_allclose(
          hls_prediction, pytorch_prediction, rtol=0, atol=5e-2
      )
  
      # Verify correct parsing of layer
      hls_pool = list(hls_model.get_layers())[-2]
      if "2d" in pooling.__name__:
          assert hls_pool.attributes["name"] == poolNode.name
          assert hls_pool.attributes["class_name"][-2] == str(2)
          assert (
              hls_pool.attributes["stride_height"]
              == class_object_pool.stride
          )
          assert (
              hls_pool.attributes["stride_width"]
              == class_object_pool.stride
          )
          assert (
              hls_pool.attributes["pool_height"]
              == class_object_pool.kernel_size
          )
          assert (
              hls_pool.attributes["pool_width"]
              == class_object_pool.kernel_size
          )
          assert (
              hls_pool.attributes["padding"] == "valid"
              if class_object_pool.padding == 0
              else "same"
          )
  
      elif "1d" in pooling.__name__:
          if "Max" in pooling.__name__:
              assert hls_pool.attributes["name"] == poolNode.name
              assert hls_pool.attributes["class_name"][-2] == str(1)
              assert (
                  hls_pool.attributes["pool_width"]
                  == class_object_pool.kernel_size
              )
              assert (
                  hls_pool.attributes["stride_width"]
                  == class_object_pool.stride
              )
              assert (
                  hls_pool.attributes["padding"] == "valid"
                  if class_object_pool.padding == 0
                  else "same"
              )
  
          else:
              assert hls_pool.attributes["name"] == poolNode.name
              assert hls_pool.attributes["class_name"][-2] == str(1)
              assert (
                  hls_pool.attributes["pool_width"]
                  == class_object_pool.kernel_size[0]
              )
              assert (
                  hls_pool.attributes["stride_width"]
                  == class_object_pool.stride[0]
              )
              assert (
                  hls_pool.attributes["padding"] == "same"
                  if class_object_pool.padding == 0
                  else "valid"
              )
  
imports: import math
  from pathlib import Path
  import numpy
  import pytest
  import torch
  import torch.nn
  from torch.nn import AvgPool1d, AvgPool2d, MaxPool1d, MaxPool2d
  from hls4ml.converters import convert_from_pytorch_model
  from hls4ml.utils.config import config_from_pytorch_model
label_desc: Use image node_id 6 for calling a global function with example usage: test_pooling(pooling, padds, backend) without return types