code: def merge_opencl_binaries_or_parameters(
      binaries_dirs,
      cl_compiled_program_file_name,
      output_file_path,
      merge_type,
  ):
      common.mace_check(
          merge_type in [MergeType.binary, MergeType.parameter],
          "",
          "Only support merge binaries or parameters, "
          "but merge type {} is got".format(merge_type),
      )
      if merge_type == MergeType.binary:
          platform_info_key = (
              "mace_opencl_precompiled_platform_info_key"
          )
      cl_bin_dirs = []
      for d in binaries_dirs:
          cl_bin_dirs.append(os.path.join(d, "opencl_bin"))
      # create opencl binary output dir
      opencl_binary_dir = os.path.dirname(output_file_path)
      if not os.path.exists(opencl_binary_dir):
          sh.mkdir("-p", opencl_binary_dir)
      kvs = {}
      CRC32SIZE = 4
      for binary_dir in cl_bin_dirs:
          binary_path = os.path.join(
              binary_dir, cl_compiled_program_file_name
          )
          if not os.path.exists(binary_path):
              continue
  
          if merge_type == MergeType.binary:
              six.print_("generate opencl code from", binary_path)
          elif merge_type == MergeType.parameter:
              six.print_("generate opencl parameter from", binary_path)
          all_bytes = open(binary_path, "rb").read()
          if len(all_bytes) < CRC32SIZE:
              print(
                  "File size of {} is less than CRC bytes".format(
                      binary_path
                  )
              )
              continue
          saved_crc = struct.unpack("I", all_bytes[-CRC32SIZE:])[0]
          current_crc = zlib.crc32(all_bytes[:-CRC32SIZE])
          # In Python2, zlib.crc32 may return negative value,
          # so casting is needed for Python2.
          current_crc = np.array([current_crc]).astype(np.uint32)[0]
          if saved_crc != current_crc:
              print("CRC value of {} is invalid".format(binary_path))
              continue
          container = mace_pb2.PairContainer()
          container.ParseFromString(all_bytes[:-CRC32SIZE])
          size = len(container.pairs)
          for i in range(size):
              pair = container.pairs[i]
              key = pair.key
              if merge_type == MergeType.binary:
                  if key == platform_info_key and key in kvs:
                      common.mace_check(
                          kvs[key] == pair.bytes_value,
                          "",
                          "There exists more than one OpenCL version for models:"
                          " %s vs %s " % (kvs[key], pair.bytes_value),
                      )
  
                  else:
                      kvs[pair.key] = pair.bytes_value
              elif merge_type == MergeType.parameter:
                  kvs[key] = pair.uint32s_value
      new_container = mace_pb2.PairContainer()
      for key in kvs:
          pair = new_container.pairs.add()
          pair.key = key
          if merge_type == MergeType.binary:
              pair.bytes_value = kvs[key]
          elif merge_type == MergeType.parameter:
              pair.uint32s_value.extend(kvs[key])
  
      message_str = new_container.SerializeToString()
      crc_val = zlib.crc32(message_str)
      crc_val = np.array([crc_val]).astype(np.uint32)[0]
      crc_bytes = struct.pack("<I", crc_val)
      with open(output_file_path, "wb") as ofp:
          ofp.write(message_str + crc_bytes)
  
imports: import glob
  import logging
  import numpy
  import zlib
  import os
  import random
  import re
  import sh
  import struct
  import sys
  import time
  import platform
  import six
  import common
  from common import abi_to_internal
label_desc: Use image node_id 28 for calling a global function with example usage: merge_opencl_binaries_or_parameters(binaries_dirs, cl_compiled_program_file_name, output_file_path, merge_type) without return types