code: def _triangular_inv(x, upper=False):
      if x.size(-1) == 1:
          return x.reciprocal()
      return torch.linalg.solve_triangular(
          x, torch.eye(x.size(-1)), upper=upper
      )
  
imports: import numbers
  import typing
  import torch
  import funsor.ops
label_desc: Use image node_id 17 for calling a global function with example usage: _triangular_inv(x, upper) and returns: torch, x