class_docstr: This class is a singleton builder to construct a MIL program. For more
  information, see `Create a MIL program <https://coremltools.readme.io/docs/model-intermediate-language#create-a-mil-program>`_.
  
  Importing ``.ops`` triggers the installation of all MIL ops into the Builder.
  For details on each op, see `MIL ops <https://apple.github.io/coremltools/source/coremltools.converters.mil.mil.ops.defs.html>`_.
  
  Examples
  --------
  
  >>> from coremltools.converters.mil.mil import Builder as mb
  >>> from coremltools.converters.mil.mil import Program, Function
  
  >>> prog = Program()
  >>> func_inputs = {"x": mb.placeholder(shape=[2,3]),
  >>>                "y": mb.placeholder(shape=[2,3])}
  >>> with Function(func_inputs) as ssa_fun:
  >>>   x, y = ssa_fun.inputs['x'], ssa_fun.inputs['y']
  >>>   res_var = mb.add(x=x, y=y) # created within ssa_fun block
  >>>   ssa_fun.set_outputs([res_var])
  >>> prog.add_function("main", ssa_fun)
  
  >>> # Importing ops triggers installation of all ops into Builder.
  >>> from .ops import defs as _ops
docstr: 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
docstr_tok: ["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"]
code: 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 = []
              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, ListOrTensorInputType)
          ):
              var = cls._add_const(val, new_var_name, before_op)
              update_dict[k] = var
  
      return update_dict
  
imports: import numbers
  from collections import defaultdict
  from typing import Callable, List, Optional
  import numpy
  from coremltools import _logger
  from coremltools.converters.mil._deployment_compatibility import AvailableTarget
  from coremltools.converters.mil.mil.types.symbolic import any_symbolic
  from .block import Function, curr_block
  from .input_type import InternalInputType, ListOrTensorInputType, TensorInputType, TupleInputType
  from .program import Placeholder, Program
  from .var import InternalVar, Var
label_desc: Use image node_id 4 for calling the Builder obj's underlying member method code with example usage: obj._create_vars(cls, input_spec, op_name, before_op, candidate_kv) and returns: update_dict