code: def avg_pool2d(
      input,
      kernel_size=1,
      stride=1,
      padding=0,
      ceil_mode=False,
      count_include_pad=True,
      divisor_override=0,
  ):
      # Figure out input dims N
      input_rank = input.ndim
  
      if input_rank == 4:
          # NCHW
          data_format = "NCHW"
  
      kernel_size = _broadcast_pooling_helper(
          kernel_size, "2d", name="kernel_size"
      )
      stride = _broadcast_pooling_helper(stride, "2d", name="stride")
      padding = _broadcast_pooling_helper(padding, "2d", name="padding")
      kernel_pads = list(zip(kernel_size, padding))
  
      # Padding should be less than or equal to half of kernel size
      if not all(pad <= kernel / 2 for kernel, pad in kernel_pads):
          raise ValueError(
              "pad should be smaller than or equal to half of kernel size, "
              f"but got padding={padding}, kernel_size={kernel_size}. "
          )
  
      # Figure out padding string
      if all(
          pad == ivy.ceil((kernel - 1) / 2)
          for kernel, pad in kernel_pads
      ):
          padding_str = "SAME"
      else:
          padding_str = "VALID"
  
      return ivy.avg_pool2d(
          input,
          kernel_size,
          stride,
          padding_str,
          data_format=data_format,
          ceil_mode=ceil_mode,
          count_include_pad=count_include_pad,
          divisor_override=divisor_override,
      )
  
imports: import ivy
  from ivy.func_wrapper import with_supported_dtypes
  from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
  from ivy.functional.ivy.experimental.layers import _broadcast_pooling_helper
label_desc: Use image node_id 4 for calling a global function with example usage: avg_pool2d(input, kernel_size, stride, padding, ceil_mode, count_include_pad, divisor_override) and returns: ivy