def _create_vars(cls, input_spec, op_name, before_op,
        candidate_kv):
        """
        For each key K in `candidate_kv`, create a Var if the
        following are satisfied:

        - K exists in input_spec and is not an InternalInputType
        - candidate_kv[K] is not already a Var

        Inputs
        ------
        - candidate_kv: Dict[str, Any]
          Key-values may be inputs to an op (whose inputs is defined by
          input_spec)

        Returns
        -------
        - var_kv: Dict[str, Var]
          For the K satisfying the above, var_kv[K] is the newly
          created Var
        """
        update_dict = {}
        for k, val in candidate_kv.items():
            if isinstance(val, Var):
                continue # already a Var

            if k not in input_spec.input_types:
                continue # k is not an op input

            in_type = input_spec.input_types[k]
            if isinstance(in_type, InternalInputType):
                new_var_name = op_name + "_" + k
                var = InternalVar(val, name=new_var_name)
                curr_block().add_internal_var(var)
                update_dict[k] = var
                continue # Not a regular Var

            new_var_name = op_name + "_" + k
            if isinstance(in_type, TupleInputType):
                var = []
                if not isinstance(val, (list, tuple)):
                    raise ValueError(f"Invalid type {type(val)} for TupleInputType param.")
                for i, v in enumerate(val):
                    if isinstance(v, Var):
                        var.append(v)
                        continue
                    var.append(
                        cls._add_const(v, new_var_name + str(i),
                          before_op)
                    )
                update_dict[k] = var
                continue

            if isinstance(in_type, (TensorInputType, ListOrTensorOrDictInputType)):
                var = cls._add_const(val, new_var_name, before_op)
                update_dict[k] = var

        return update_dict

        For each key K in `candidate_kv`, create a Var if the
        following are satisfied:

        - K exists in input_spec and is not an InternalInputType
        - candidate_kv[K] is not already a Var

        Inputs
        ------
        - candidate_kv: Dict[str, Any]
          Key-values may be inputs to an op (whose inputs is defined by
          input_spec)

        Returns
        -------
        - var_kv: Dict[str, Var]
          For the K satisfying the above, var_kv[K] is the newly
          created Var
        
coremltools/converters/mil/mil/builder.py