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","."]
code: def eager_reduce(self, op, reduced_vars):
      assert reduced_vars.issubset(self.arg.inputs)
      return Constant(
          self.const_inputs, self.arg.reduce(op, reduced_vars)
      )
  
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 3 for calling the Constant obj's underlying member method code with example usage: obj.eager_reduce(op, reduced_vars) and returns: Constant