code: #
  # pool2d paddle model generator
  #
  import numpy as np
  from save_model import saveModel
  import sys
  
  def yolo_box(name : str, x, img_size, attrs : dict):
      import paddle as pdpd
      pdpd.enable_static()
      
      with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()):
          node_x = pdpd.static.data(name='x', shape=x.shape, dtype=x.dtype)
          node_img_size = pdpd.static.data(name='img_size', shape=img_size.shape, dtype=img_size.dtype)
          boxes, scores = pdpd.vision.ops.yolo_box(node_x,
                                                  node_img_size,
                                                  anchors=attrs['anchors'],
                                                  class_num=attrs['class_num'],
                                                  conf_thresh=attrs['conf_thresh'],
                                                  downsample_ratio=attrs['downsample_ratio'],
                                                  clip_bbox=attrs['clip_bbox'],
                                                  name=None, 
                                                  scale_x_y=attrs['scale_x_y'])
  
          cpu = pdpd.static.cpu_places(1)
          exe = pdpd.static.Executor(cpu[0])
          # startup program will call initializer to initialize the parameters.
          exe.run(pdpd.static.default_startup_program())
  
          outs = exe.run(
              feed={'x': x, 'img_size': img_size},
              fetch_list=[boxes, scores])
          
          # Save inputs in order of ngraph function, to facilite Fuzzy test, 
          # which accepts inputs and outputs in this order as well. 
          saveModel(name, exe, feedkeys=['x', 'img_size'], fetchlist=[boxes, scores],
                    inputs=[x, img_size], outputs=outs, target_dir=sys.argv[1])
  
      return outs
  
  
  def TEST1():
      # yolo_box
      pdpd_attrs = {
              'name': "yolo_box_default",
              'anchors': [10, 13, 16, 30, 33, 23],
              'class_num': 2,
              'conf_thresh': 0.5,
              'downsample_ratio': 32,
              'clip_bbox': False,
              'scale_x_y': 1.0
      }
  
      pdpd_attrs_clip_box = {
          'name': "yolo_box_clip_box",
          'anchors': [10, 13, 16, 30, 33, 23],
          'class_num': 2,
          'conf_thresh': 0.5,
          'downsample_ratio': 32,
          'clip_bbox': True,
          'scale_x_y': 1.0
      }
  
      pdpd_attrs_scale_xy = {
          'name': "yolo_box_scale_xy",
          'anchors': [10, 13, 16, 30, 33, 23],
          'class_num': 2,
          'conf_thresh': 0.5,
          'downsample_ratio': 32,
          'clip_bbox': True,
          'scale_x_y': 1.2
      }
  
      pdpd_attrs_list = [pdpd_attrs, pdpd_attrs_clip_box, pdpd_attrs_scale_xy]
      
      N = 32
      num_anchors = int(len(pdpd_attrs['anchors'])//2)
      x_shape = (N, num_anchors * (5 + pdpd_attrs['class_num']), 13, 13)
      imgsize_shape = (N, 2)
  
      data = np.random.random(x_shape).astype('float32')
      data_ImSize = np.random.randint(10, 20, imgsize_shape).astype('int32') 
  
      for item in pdpd_attrs_list:
          pred_pdpd = yolo_box(item['name'], data, data_ImSize, item)
  
  
  def TEST2():
      # yolo_box uneven spatial width and height
      pdpd_attrs = {
              'name': "yolo_box_uneven_wh",
              'anchors': [10, 13, 16, 30, 33, 23],
              'class_num': 2,
              'conf_thresh': 0.5,
              'downsample_ratio': 32,
              'clip_bbox': False,
              'scale_x_y': 1.0
      }
  
      N = 16
      SPATIAL_WIDTH = 13
      SPATIAL_HEIGHT = 9
      num_anchors = int(len(pdpd_attrs['anchors'])//2)
      x_shape = (N, num_anchors * (5 + pdpd_attrs['class_num']), SPATIAL_HEIGHT, SPATIAL_WIDTH)
      imgsize_shape = (N, 2)
  
      data = np.random.random(x_shape).astype('float32')
      data_ImSize = np.random.randint(10, 20, imgsize_shape).astype('int32')
      
      pred_pdpd = yolo_box(pdpd_attrs['name'], data, data_ImSize, pdpd_attrs)
  
  if __name__ == "__main__":
      TEST1()
      TEST2() # Copyright (C) 2018-2021 Intel Corporation
  # SPDX-License-Identifier: Apache-2.0
  
  import numpy as np
  
  from openvino.tools.mo.ops.LSTM import LSTM
  from openvino.tools.mo.front.extractor import FrontExtractorOp
  from openvino.tools.mo.front.onnx.extractors.utils import onnx_attr
  
  
  class LSTMFrontExtractor(FrontExtractorOp):
      op = 'LSTM'
      enabled = True
  
      @classmethod
      def extract(cls, node):
          activation_alpha = onnx_attr(node, 'activation_alpha', 'floats',
                                       default=None, dst_type=lambda x: np.array(x, dtype=np.float32))
          activation_beta = onnx_attr(node, 'activation_beta', 'floats',
                                       default=None, dst_type=lambda x: np.array(x, dtype=np.float32))
          activations = onnx_attr(node, 'activations', 'strings', default=None,
                                  dst_type=lambda x: list(map(lambda s: s.decode(encoding="utf-8").lower(), list(x))))
          clip = onnx_attr(node, 'clip', 'f', default=None)
          input_forget = onnx_attr(node, 'input_forget', 'i', default=0)
  
          attrs = {
              'batch_dim': 1,
              'sequence_dim': 0,
              'blobs_wrb': True,
              'has_num_directions': True,
              'num_layers': 1,
              'format': 'onnx',
              'multilayers': False,
              'gate_order': [2, 0, 3, 1],  # iofc --> fico
  
              # ONNX attrs
              'activation_alpha': activation_alpha,
              'activation_beta': activation_beta,
              'activations': activations,
              'clip': clip,
              'direction': onnx_attr(node, 'direction', 's', b'forward').decode().lower(),
              'hidden_size': np.array(onnx_attr(node, 'hidden_size', 'i'), dtype=np.int64),
              'input_forget': input_forget,
          }
  
          LSTM.update_node_stat(node, attrs)
          return cls.enabled
  
apis: numpy.random.random numpy.random.randint
apis: numpy.array