class_docstr: Jit-compatible helper to build blockwise vectors.
  Syntax is similar to :func:`torch.zeros` ::
  
      x = BlockVector((100, 20))
      x[..., 0:4] = x1
      x[..., 6:10] = x2
      x = x.as_tensor()
      assert x.shape == (100, 20)
class_docstr_tok: ["Jit-compatible","helper","to","build","blockwise","vectors",".","Syntax","is","similar","to",":","func",":","`","torch.zeros","`",":",":","x","=","BlockVector","(","(","100",",","20",")",")","x","[","...",",","0:4","]","=","x1","x","[","...",",","6:10","]","=","x2","x","=","x.as_tensor","(",")","assert","x.shape","==","(","100",",","20",")"]
code: def as_tensor(self):
      # TODO optimize this to use backend-specific block setters:
      # .__setitem__ for numpy and torch; .at(...).set(...) for jax.
  
      # Fill gaps with zeros.
      prototype = next(iter(self.parts.values()))
      for i in _find_intervals(self.parts.keys(), self.shape[-1]):
          if i not in self.parts:
              self.parts[i] = ops.new_zeros(
                  prototype, self.shape[:-1] + (i[1] - i[0],)
              )
  
      # Concatenate parts.
      parts = [v for k, v in sorted(self.parts.items())]
      result = ops.cat(parts, -1)
      if not get_tracing_state():
          assert result.shape == self.shape
      return result
  
imports: import math
  from collections import OrderedDict, defaultdict
  from contextlib import contextmanager
  from functools import reduce
  import funsor.ops
  from funsor.affine import affine_inputs, extract_affine, is_affine
  from funsor.delta import Delta
  from funsor.domains import Real, Reals
  from funsor.interpretations import compress_gaussians
  from funsor.ops import AddOp, SubOp
  from funsor.tensor import Tensor, align_tensor, align_tensors
  from funsor.terms import Binary, Funsor, FunsorMeta, Number, Slice, Subs, Variable, eager, reflect
  from funsor.util import broadcast_shape, get_tracing_state, lazy_property
label_desc: Use image node_id 3 for calling the BlockVector obj's underlying member method code with example usage: obj.as_tensor() and returns: result