code: def _convert_multiarray_output_to_image(
      spec,  # type: Any
      feature_name,  # type: Text
      is_bgr=False,  # type: bool
  ):
      # type: (...) -> None
      for output in spec.description.output:
          if output.name != feature_name:
              continue
          if output.type.WhichOneof("Type") != "multiArrayType":
              raise ValueError(
                  "{} is not a multiarray type".format(
                      output.name,
                  )
              )
          array_shape = tuple(output.type.multiArrayType.shape)
          if len(array_shape) == 2:
              height, width = array_shape
              output.type.imageType.colorSpace = (
                  ft.ImageFeatureType.ColorSpace.Value("GRAYSCALE")
              )
          else:
              if len(array_shape) == 4:
                  if array_shape[0] != 1:
                      raise ValueError(
                          "Shape {} is not supported for image output".format(
                              array_shape,
                          )
                      )
                  array_shape = array_shape[1:]
  
              channels, height, width = array_shape
  
              if channels == 1:
                  output.type.imageType.colorSpace = (
                      ft.ImageFeatureType.ColorSpace.Value("GRAYSCALE")
                  )
              elif channels == 3:
                  if is_bgr:
                      output.type.imageType.colorSpace = (
                          ft.ImageFeatureType.ColorSpace.Value("BGR")
                      )
                  else:
                      output.type.imageType.colorSpace = (
                          ft.ImageFeatureType.ColorSpace.Value("RGB")
                      )
              else:
                  raise ValueError(
                      "Channel Value {} is not supported for image output".format(
                          channels,
                      )
                  )
  
          output.type.imageType.width = width
          output.type.imageType.height = height
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from typing import Text, Union, Optional, Dict, Any, Iterable, Sequence, Callable, List
  import numpy
  from coremltools._deps import _HAS_ONNX
  from coremltools.models.neural_network import NeuralNetworkBuilder
  from coremltools.models import datatypes, MLModel
  from coremltools.proto import FeatureTypes_pb2
  from coremltools import _MINIMUM_CUSTOM_LAYER_SPEC_VERSION
  from coremltools import _MINIMUM_CUSTOM_MODEL_SPEC_VERSION
  from coremltools import _MINIMUM_NDARRAY_SPEC_VERSION
  from coremltools import __version__
  from coremltools.models import _METADATA_VERSION, _METADATA_SOURCE
  from typing import Tuple
  from ._operators import _convert_node, _SEQUENCE_LAYERS_REGISTRY, _ONNX_NODE_REGISTRY, _add_const_inputs_if_required
  from ._operators_nd import _ONNX_NODE_REGISTRY_ND, _convert_node_nd
  from ._graph import Graph, EdgeInfo, Transformer
  from ._transformers import ConvAddFuser, DropoutRemover, ReshapeInitTensorFuser, BNBroadcastedMulFuser, BNBroadcastedAddFuser, PixelShuffleFuser, OutputRenamer, AddModelInputsOutputs, ConstantsToInitializers, ImageScalerRemover, ShapeOpRemover, ConstantRemover, ConstantFillToInitializers, ReshapeTransposeReshape_pattern1, CastOpRemover, DeadCodeElimination, PaddingOpRemover
  from coremltools.converters.mil.backend.nn.passes.mlmodel_passes import remove_disconnected_layers, transform_conv_crop
  from ._error_utils import ErrorHandling
  from ._graph_viz import plot_graph
label_desc: Use image node_id 7 for calling a global function with example usage: _convert_multiarray_output_to_image(spec, feature_name, is_bgr) without return types