code: def main(args):
      funsor.set_backend("torch")
  
      # Problem definition.
      N = 100
      P = 10
      data = Tensor(torch.randn(N, P))["n"]
      true_weight = Tensor(torch.randn(P))
      true_bias = Tensor(torch.randn(()))
      truth = true_bias + true_weight @ data
  
      # Model.
      weight = Variable("weight", Reals[P])
      bias = Variable("bias", Real)
      pred = bias + weight @ data
      loss = (pred - truth).abs().reduce(ops.add, "n")
  
      # Inference.
      with Adam(
          args.num_steps,
          lr=args.learning_rate,
          log_every=args.log_every,
      ) as optim:
          loss.reduce(ops.min, {"weight", "bias"})
  
      print(f"True bias\n{true_bias}")
      print("Learned bias\n{}".format(optim.param("bias")))
      print(f"True weight\n{true_weight}")
      print("Learned weight\n{}".format(optim.param("weight")))
  
file_path: funsor/examples/adam.py
imports: import argparse
  import torch
  import funsor
  import funsor.ops
  from funsor.adam import Adam
  from funsor.domains import Real, Reals
  from funsor.tensor import Tensor
  from funsor.terms import Variable
label_desc: Use image node_id 1 for calling a global function with example usage: main(args) without return types