code: def log1pexp(x: Tensor) -> Tensor:
      """Numerically accurate evaluation of log(1 + exp(x)).
      See [Maechler2012accurate]_ for details.
      """
      mask = x <= 18
      return torch.where(
          mask,
          (lambda z: z.exp().log1p())(x.masked_fill(~mask, 0)),
          (lambda z: z + (-z).exp())(x.masked_fill(mask, 0)),
      )
  
imports: from __future__ import annotations
  import math
  from typing import Callable, Tuple, Union
  import torch
  from botorch.exceptions import UnsupportedError
  from botorch.utils.constants import get_constants_like
  from torch import finfo, Tensor
  from torch.nn.functional import softplus
label_desc: Use image node_id 8 for calling a global function with example usage: log1pexp(x) and returns: torch