code: def convert_upsample(
      builder,
      layer,
      input_names,
      output_names,
      keras_layer,
      respect_train,
  ):
      """
      Convert upsample layer from keras to coreml.
  
      Parameters
      ----------
      keras_layer: layer
          A keras layer object.
  
      builder: NeuralNetworkBuilder
          A neural network builder object.
      respect_train: boolean
          Ignored.
      """
      _check_data_format(keras_layer)
      # Get input and output names
      input_name, output_name = (input_names[0], output_names[0])
  
      is_1d = isinstance(keras_layer, _keras.layers.UpSampling1D)
  
      # Currently, we only support upsample of same dims
      fh = fw = 1
      if is_1d:
          if (
              type(keras_layer.size) is tuple
              and len(keras_layer.size) == 1
          ):
              fh, fw = 1, keras_layer.size[0]
          elif type(keras_layer.size) is int:
              fh, fw = 1, keras_layer.size
          else:
              raise ValueError(
                  "Unrecognized upsample factor format %s"
                  % (str(keras_layer.size))
              )
      else:
          if type(keras_layer.size) is int:
              fh = fw = keras_layer.size
          elif len(keras_layer.size) == 2:
              if keras_layer.size[0] != keras_layer.size[1]:
                  raise ValueError(
                      "Upsample with different rows and columns not "
                      "supported."
                  )
              else:
                  fh = keras_layer.size[0]
                  fw = keras_layer.size[1]
          else:
              raise ValueError(
                  "Unrecognized upsample factor format %s"
                  % (str(keras_layer.size))
              )
  
      kerasmode2coreml = {"nearest": "NN", "bilinear": "BILINEAR"}
      interpolation = getattr(
          keras_layer, "interpolation", "nearest"
      )  # Defaults to 'nearest' for Keras < 2.2.3
  
      if interpolation not in kerasmode2coreml:
          raise ValueError(
              'Only supported "nearest" or "bilinear" interpolation for upsampling layers.'
          )
  
      mode = kerasmode2coreml[interpolation]
  
      builder.add_upsample(
          name=layer,
          scaling_factor_h=fh,
          scaling_factor_w=fw,
          input_name=input_name,
          output_name=output_name,
          mode=mode,
      )
  
imports: from .None import _utils
  import logging
  import keras
  import numpy
  from ...proto import NeuralNetwork_pb2
  from distutils.version import StrictVersion
label_desc: Use image node_id 19 for calling a global function with example usage: convert_upsample(builder, layer, input_names, output_names, keras_layer, respect_train) without return types