code: def cdf(self, x):
      gamma, b, knot_positions = self.gamma, self.b, self.knot_positions
  
      quantiles_at_knots = self.quantile_internal(
          knot_positions, dim=-2
      )
  
      # Mask to nullify the terms corresponding to knots larger than l_0,
      # which is the largest knot (quantile level) such that the quantile
      # at l_0, s(l_0) < x.
      mask = torch.le(quantiles_at_knots, x.unsqueeze(-1))
  
      slope_l0 = (b * mask).sum(-1)
  
      # slope_l0 can be zero in which case a_tilde = 0.
      # The following is to circumvent an issue where the
      # backward() returns nans when slope_l0 is zero in the where
      slope_l0_nz = torch.where(
          slope_l0 == 0.0, torch.ones_like(x), slope_l0
      )
  
      a_tilde = torch.where(
          slope_l0 == 0.0,
          torch.zeros_like(x),
          (x - gamma + (b * knot_positions * mask).sum(-1))
          / slope_l0_nz,
      )
  
      return torch.clamp(a_tilde, min=0.0, max=1.0)
  
file_path: gluonts/src/gluonts/nursery/robust-mts-attack/pts/distributions/piecewise_linear.py
imports: import torch
  import torch.nn.functional
  from torch.distributions import constraints, NegativeBinomial, Poisson, Distribution, TransformedDistribution, AffineTransform
  from torch.distributions.utils import broadcast_all, lazy_property
  from .utils import broadcast_shape
label_desc: Use image node_id 7 for calling the PiecewiseLinear obj's underlying member method code with example usage: obj.cdf(x) and returns: torch