code: def _find_block_config_with_vela(
      npu_op: vapi.NpuOperation, accelerator: vapi.NpuAccelerator
  ) -> vapi.NpuShape3D:
      """An internal function to get block config using Vela's logic.
  
      Parameters
      ----------
      npu_op : ethosu.vela.api.NpuOperation
          The NPU operation
      accelerator : ethosu.vela.api.NpuAccelerator
          The NPU accelerator
  
      Returns
      -------
      ethosu.vela.api.NpuShape3D :
          The optimal block config for the operator
      """
      if isinstance(npu_op, vapi.NpuConv2DOperation):
          block_type = NpuBlockType.ConvolutionMxN
      elif isinstance(npu_op, vapi.NpuConvDepthWiseOperation):
          block_type = NpuBlockType.ConvolutionDepthWise
      elif isinstance(npu_op, vapi.NpuPoolingOperation):
          block_type = (
              NpuBlockType.ReduceSum
              if npu_op.sub_op_type == vapi.NpuPoolingOp.REDUCE_SUM
              else NpuBlockType.Pooling
          )
      elif isinstance(npu_op, vapi.NpuElementWiseOperation):
          block_type = NpuBlockType.ElementWise
      else:
          assert 0, "Unsupported operation"
  
      ifm_shape = Shape4D(
          1,
          npu_op.ifm.shape.height,
          npu_op.ifm.shape.width,
          npu_op.ifm.shape.depth,
      )
      ifm2_shape = None
      if npu_op.ifm2:
          ifm2_shape = Shape4D(
              1,
              npu_op.ifm2.shape.height,
              npu_op.ifm2.shape.width,
              npu_op.ifm2.shape.depth,
          )
      ofm_shape = Shape4D(
          1,
          npu_op.ofm.shape.height,
          npu_op.ofm.shape.width,
          npu_op.ofm.shape.depth,
      )
  
      ifm_resampling_mode = resampling_mode_map[npu_op.ifm_upscale]
      ifm_bits = npu_op.ifm.data_type.size_in_bits()
      lut_banks = 0
      if npu_op.activation:
          lut_banks = (
              2
              if npu_op.activation.op_type
              == vapi.NpuActivationOp.TABLE_LOOKUP
              else 0
          )
  
      has_scaling = True
      for tensor in [npu_op.ifm, npu_op.ifm2, npu_op.ofm]:
          if tensor and tensor.quantization is None:
              has_scaling = False
              break
  
      arch = create_default_arch(
          Accelerator.from_npu_accelerator(accelerator)
      )
  
      cfg = find_block_config(
          arch,
          block_type,
          ofm_shape,
          ifm_shape,
          ifm2_shape,
          npu_op.ifm2_scalar is not None,
          ifm_bits,
          to_kernel(npu_op.kernel),
          lut_banks,
          has_scaling,
          ifm_resampling_mode,
      )
      assert (
          cfg is not None
      ), f"There is no configuration suitable for {accelerator}"
      return vapi.NpuShape3D(
          cfg.ofm_block.height, cfg.ofm_block.width, cfg.ofm_block.depth
      )
  
imports: import logging
  import math
  from typing import List, Optional, Tuple
  import numpy
  from ethosu.vela import api
  from ethosu.vela.architecture_allocator import find_block_config
  from ethosu.vela.architecture_features import Accelerator, create_default_arch
  from ethosu.vela.operation import NpuBlockType
  from ethosu.vela.register_command_stream_generator import resampling_mode_map
  from ethosu.vela.register_command_stream_util import to_kernel
  from ethosu.vela.shape4d import Shape4D
  import tvm
  from tvm.relay.backend.contrib.ethosu import tir_to_cs_translator
  from tvm.relay.backend.contrib.ethosu import util
label_desc: Use image node_id 2 for calling a global function with example usage: _find_block_config_with_vela(npu_op, accelerator) and returns: vapi