code: def _get_offset_by_writing_data(output_var, blob_writer):
      if (
          output_var.val.dtype.kind == "f"
          and output_var.val.dtype.itemsize == 4
      ):
          offset = blob_writer.write_float_data(
              np.ascontiguousarray(output_var.val.flatten())
          )
      elif (
          output_var.val.dtype.kind == "f"
          and output_var.val.dtype.itemsize == 2
      ):
          output_var_fp16_to_bytes_to_uint16 = np.frombuffer(
              output_var.val.flatten().tobytes(), np.uint16
          )
          offset = blob_writer.write_fp16_data(
              np.ascontiguousarray(output_var_fp16_to_bytes_to_uint16)
          )
      elif (
          output_var.val.dtype.kind == "u"
          and output_var.val.dtype.itemsize == 1
      ):
          offset = blob_writer.write_uint8_data(
              np.ascontiguousarray(output_var.val.flatten())
          )
      elif (
          output_var.val.dtype.kind == "i"
          and output_var.val.dtype.itemsize == 1
      ):
          offset = blob_writer.write_int8_data(
              np.ascontiguousarray(output_var.val.flatten())
          )
      elif (
          output_var.val.dtype.kind == "u"
          and output_var.val.dtype.itemsize == 2
      ):
          offset = blob_writer.write_uint16_data(
              np.ascontiguousarray(output_var.val.flatten())
          )
      elif (
          output_var.val.dtype.kind == "i"
          and output_var.val.dtype.itemsize == 2
      ):
          offset = blob_writer.write_int16_data(
              np.ascontiguousarray(output_var.val.flatten())
          )
      else:
          raise TypeError(
              "Unsupported type, {}, for net buffer serialization.".format(
                  output_var.val.dtype
              )
          )
  
      return offset
  
imports: import os
  import numpy
  import coremltools.proto.FeatureTypes_pb2
  import coremltools.proto.MIL_pb2
  from coremltools.converters.mil.mil import types
  from coremltools.converters.mil.mil.types import BUILTIN_TO_PROTO_TYPES, builtin_to_string, numpy_type_to_builtin_type, type_to_builtin_type
  from coremltools.converters.mil.mil.types.type_mapping import np_val_to_py_type
  from coremltools.models.utils import _WEIGHTS_DIR_NAME, _WEIGHTS_FILE_NAME
label_desc: Use image node_id 17 for calling a global function with example usage: _get_offset_by_writing_data(output_var, blob_writer) and returns: offset