class_docstr: Funsor that is constant wrt ``const_inputs``.
  
  :class:`Constant` can be used for provenance tracking.
  
  Examples::
  
      a = Constant(OrderedDict(x=Real, y=Bint[3]), Number(0))
      a(y=1)  # returns Constant(OrderedDict(x=Real), Number(0))
      a(x=2, y=1)  # returns Number(0)
  
      d = Tensor(torch.tensor([1, 2, 3]))["y"]
      a + d  # returns Constant(OrderedDict(x=Real), d)
  
      c = Constant(OrderedDict(x=Bint[3]), Number(1))
      c.reduce(ops.add, "x")  # returns Number(3)
  
  :param dict const_inputs: A mapping from input name (str) to datatype (``funsor.domain.Domain``).
  :param funsor arg: A funsor that is constant wrt to const_inputs.
class_docstr_tok: ["Funsor","that","is","constant","wrt","``","const_inputs","``",".",":","class",":","`","Constant","`","can","be","used","for","provenance","tracking",".","Examples",":",":","a","=","Constant","(","OrderedDict","(","x=Real",",","y=Bint","[","3","]",")",",","Number","(","0",")",")","a","(","y=1",")","#","returns","Constant","(","OrderedDict","(","x=Real",")",",","Number","(","0",")",")","a","(","x=2",",","y=1",")","#","returns","Number","(","0",")","d","=","Tensor","(","torch.tensor","(","[","1",",","2",",","3","]",")",")","[","``","y","''","]","a","+","d","#","returns","Constant","(","OrderedDict","(","x=Real",")",",","d",")","c","=","Constant","(","OrderedDict","(","x=Bint","[","3","]",")",",","Number","(","1",")",")","c.reduce","(","ops.add",",","``","x","''",")","#","returns","Number","(","3",")",":","param","dict","const_inputs",":","A","mapping","from","input","name","(","str",")","to","datatype","(","``","funsor.domain.Domain","``",")",".",":","param","funsor","arg",":","A","funsor","that","is","constant","wrt","to","const_inputs","."]
docstr: Attempt to convert a Funsor to a :class:`~funsor.terms.Number` or
  :class:`Tensor` by substituting :func:`arange` s into its free variables.
  
  :arg Funsor x: A funsor.
  :rtype: Funsor
docstr_tok: ["Attempt","to","convert","a","Funsor","to","a",":","class",":","`","~funsor.terms.Number","`","or",":","class",":","`","Tensor","`","by","substituting",":","func",":","`","arange","`","s","into","its","free","variables",".",":","arg","Funsor","x",":","A","funsor",".",":","rtype",":","Funsor"]
code: def materialize(self, x):
      """
      Attempt to convert a Funsor to a :class:`~funsor.terms.Number` or
      :class:`Tensor` by substituting :func:`arange` s into its free variables.
  
      :arg Funsor x: A funsor.
      :rtype: Funsor
      """
      assert isinstance(x, Funsor)
      if isinstance(x, (Number, Tensor)):
          return x
  
      assert isinstance(self.arg, Tensor)
      return self.arg.materialize(x)
  
file_path: funsor/funsor/constant.py
imports: from collections import OrderedDict
  from functools import reduce
  import funsor.ops
  from funsor.tensor import Tensor
  from funsor.terms import Binary, Funsor, FunsorMeta, Number, Reduce, Unary, Variable, eager
label_desc: Use image node_id 5 for calling the Constant obj's underlying member method code with example usage: obj.materialize(x) and returns: self, x