def add_optionals(self, optionals_in, optionals_out):
        """
        Add optional inputs and outputs to the model spec.

        Parameters
        ----------
        optionals_in: list of str
            List of inputs that are optionals.

        optionals_out: list of str
            List of outputs that are optionals.

        See Also
        --------
        set_input, set_output

        """
        spec = self.spec
        if (not optionals_in) and (not optionals_out):
            return

        input_types = [
            datatypes.Array(dim) if isinstance(dim, int) else datatypes.Array(*dim)
            for (name, dim) in optionals_in
        ]
        output_types = []
        for name, dim in optionals_out:
            if not dim:
                output_types.append(None)
            elif isinstance(dim, int):
                output_types.append(datatypes.Array(dim))
            else:
                output_types.append(datatypes.Array(*dim))

        input_names = [str(name) for (name, dim) in optionals_in]
        output_names = [str(name) for (name, dim) in optionals_out]

        input_features = list(zip(input_names, input_types))
        output_features = list(zip(output_names, output_types))

        len_before_in = len(spec.description.input)
        len_before_out = len(spec.description.output)

        # this appends to the existing model interface
        set_transform_interface_params(spec, input_features, output_features, True)

        # add types for any extra hidden inputs
        for idx in range(len_before_in, len(spec.description.input)):
            spec.description.input[
                idx
            ].type.multiArrayType.dataType = _proto.Model_pb2.ArrayFeatureType.DOUBLE
        for idx in range(len_before_out, len(spec.description.output)):
            spec.description.output[
                idx
            ].type.multiArrayType.dataType = _proto.Model_pb2.ArrayFeatureType.DOUBLE

        Add optional inputs and outputs to the model spec.

        Parameters
        ----------
        optionals_in: list of str
            List of inputs that are optionals.

        optionals_out: list of str
            List of outputs that are optionals.

        See Also
        --------
        set_input, set_output

        
coremltools/models/neural_network/builder.py