class_docstr: An auto-batching DSL context.
  
  Auto-batching DSL operations are methods on the `ProgramBuilder` object.  It's
  used like this:
  
  ```python
  ab = dsl.ProgramBuilder()
  
  def fib_type(arg_types):
    return arg_types[0]
  
  with ab.function(type_inference=fib_type) as fibonacci:
    n = ab.param('n')
    ab.var.cond = ab.primop(lambda n: n > 1)
    with ab.if_(ab.var.cond):
      ab.var.nm1 = ab.primop(lambda n: n - 1)
      ab.var.fibm1 = ab.call(fibonacci, [ab.var.nm1])
      ab.var.nm2 = ab.primop(lambda n: n - 2)
      ab.var.fibm2 = ab.call(fibonacci, [ab.var.nm2])
      ab.var.ans = ab.primop(lambda fibm1, fibm2: fibm1 + fibm2)
    with ab.else_():
      ab.var.ans = ab.const(1)
    ab.return_(ab.var.ans)
  
  prog = ab.program(main=fibonacci)
  # Now `prog` is a well-formed `instructions.Program`, and the context
  # `ab` is no longer needed.
  ```
  
  Note the sequence of method calls on `ProgramBuilder` corresponds to the
  source code of the `Program` being defined, not its runtime behavior.  This is
  because (a) functions are defined with a context manager (rather than a Python
  function) which executes its body immediately and exactly once; and (b)
  function call instructions (and primitive operations) are just recorded, not
  entered recursively.
docstr: Declares a local variable in the current scope.
  
  This should typically not be needed, because `ProgramBuilder.var.foo =` can
  bind variables; however, may be helpful for a multivalue return (see
  `primop` or `call`).
  
  Args:
    name: Optional Python string to serve a mnemonic name in later compiler
      stages.  Variable names are automatically uniqued.  This variable can
      later be referred to with `ProgramBuilder.var.name`, as well as through
      any Python binding of the returned value.
    define: Boolean giving whether to mark this variable defined on creation.
      Default `True`.  Setting `False` is useful for speculatively uniquing a
      variable on its first appearance, before knowning whether said
      appearance is a write (in which case the variable becomes defined) or a
      read (which raises an error).
  
  Returns:
    var: A Python string representing this variable.  Suitable for passing
      to `primop`, `call`, `if_`, and `return_`.
code: def local(self, name=None, define=True):
      """Declares a local variable in the current scope.
  
      This should typically not be needed, because `ProgramBuilder.var.foo =` can
      bind variables; however, may be helpful for a multivalue return (see
      `primop` or `call`).
  
      Args:
        name: Optional Python string to serve a mnemonic name in later compiler
          stages.  Variable names are automatically uniqued.  This variable can
          later be referred to with `ProgramBuilder.var.name`, as well as through
          any Python binding of the returned value.
        define: Boolean giving whether to mark this variable defined on creation.
          Default `True`.  Setting `False` is useful for speculatively uniquing a
          variable on its first appearance, before knowning whether said
          appearance is a write (in which case the variable becomes defined) or a
          read (which raises an error).
  
      Returns:
        var: A Python string representing this variable.  Suitable for passing
          to `primop`, `call`, `if_`, and `return_`.
      """
      self._prepare_for_instruction()
      self._varcount += 1
      if name is not None:
          var = "{}_{}".format(name, self._varcount)
      else:
          var = "var_{}".format(self._varcount)
      if name is not None and name not in self._locals:
          self._locals[name] = var
      if define:
          self._mark_defined(var)
      return var
  
imports: import collections
  import contextlib
  import inspect
  from tensorflow_probability.python.experimental.auto_batching import instructions
label_desc: Use image node_id 8 for calling the ProgramBuilder obj's underlying member method code with example usage: obj.local(name, define) and returns: var