class_docstr: QNN AvgPool2d test class.
docstr: Test qnn.avg_pool2d
docstr_tok: ["Test","qnn.avg_pool2d"]
code: def test_qnn_avg_pool2d(
      self,
      hexagon_session: Session,
      idtype,
      odtype,
      input_shape,
      kernel,
      stride,
      dilation,
      padding,
      ceil_mode,
      count_include_pad,
      layout,
  ):
      """Test qnn.avg_pool2d"""
  
      def gen_relay_expr_qnn(
          dtype,
          input_scale,
          input_zero_point,
          output_scale,
          output_zero_point,
      ):
          data = relay.var("data", shape=input_shape, dtype=dtype)
          qnn_avg_pool = relay.qnn.avg_pool2d(
              data,
              input_scale=relay.const(input_scale),
              input_zero_point=relay.const(input_zero_point),
              output_scale=relay.const(output_scale),
              output_zero_point=relay.const(output_zero_point),
              pool_size=kernel,
              strides=stride,
              dilation=dilation,
              padding=padding,
              ceil_mode=ceil_mode,
              count_include_pad=count_include_pad,
              layout=layout,
          )
  
          return qnn_avg_pool
  
      # Generate inputs and reference data first.
      fp_input = np.random.random(input_shape)
      fp_output = tvm.topi.testing.poolnd_python(
          fp_input,
          kernel,
          stride,
          dilation,
          padding_before=padding[:2],
          padding_after=padding[2:],
          pool_type="avg",
          count_include_pad=count_include_pad,
          ceil_mode=ceil_mode,
          layout=layout,
      )
      input_data, input_scale, input_zero_point = quantize_np(
          fp_input, idtype
      )
      ref_out, output_scale, output_zero_point = quantize_np(
          fp_output, odtype
      )
      inputs = {"data": input_data}
  
      relay_mod = tvm.IRModule.from_expr(
          gen_relay_expr_qnn(
              idtype,
              input_scale,
              input_zero_point,
              output_scale,
              output_zero_point,
          )
      )
  
      hexagon_mod = build_hexagon_module(relay_mod)
      hexagon_outs = execute_on_hexagon(
          hexagon_session, hexagon_mod, inputs
      )
      assert_allclose(hexagon_outs, [ref_out], rtol=0, atol=2)
  
imports: import numpy
  import tvm.testing
  import tvm.topi.testing
  from tvm import relay
  from tvm.contrib.hexagon.session import Session
  from tvm.contrib.hexagon.pytest_plugin import HEXAGON_AOT_LLVM_TARGET
  from tvm.relay.backend import Executor
  from tvm.relay.testing import run_opt_pass, run_infer_type
  from .infrastructure import quantize_np
label_desc: Use image node_id 1 for calling the TestQnnAvgPool2d obj's underlying member method code with example usage: obj.test_qnn_avg_pool2d(hexagon_session, idtype, odtype, input_shape, kernel, stride, dilation, padding, ceil_mode, count_include_pad, layout) and returns: qnn_avg_pool