<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_upsample(self, name, scaling_factor_h, scaling_factor_w, input_name, output_name, mode = 'NN'):
 """ Add upsample layer to the model. Parameters name: str The name of this layer. scaling_factor_h: int Scaling factor on the vertical direction. scaling_factor_w: int Scaling factor on the horizontal direction. input_name: str The input blob name of this layer. output_name: str The output blob name of this layer. mode: str Following values are supported: 'NN': nearest neighbour 'BILINEAR' : bilinear interpolation See Also -------- add_sequence_repeat, add_elementwise """

        spec = self.spec
        nn_spec = self.nn_spec

        # Add a new inner-product layer
        spec_layer = nn_spec.layers.add()
        spec_layer.name = name
        spec_layer.input.append(input_name)
        spec_layer.output.append(output_name)
        spec_layer_params = spec_layer.upsample
        spec_layer_params.scalingFactor.append(scaling_factor_h)
        spec_layer_params.scalingFactor.append(scaling_factor_w)
        if mode == 'NN':
            spec_layer_params.mode = _NeuralNetwork_pb2.UpsampleLayerParams.InterpolationMode.Value('NN')
        elif mode == 'BILINEAR':
            spec_layer_params.mode = _NeuralNetwork_pb2.UpsampleLayerParams.InterpolationMode.Value('BILINEAR')
        else:
            raise ValueError("Unsupported upsampling mode %s" % mode)