code: def quantile_internal(
      self, u: torch.Tensor, dim: Optional[int] = None
  ) -> torch.Tensor:
      # output shape = u.shape
      if dim is not None:
          # when num_samples!=None
          #
          # In testing
          # dim = 0
          # u.shape          = (num_samples, *batch_shape)
          # gamma.shape      = (1, *batch_shape)
          # other_para.shape = (1, *batch_shape, num_pieces)
          #
          # In training, u_tilde is needed to compute CRPS
          # dim = -2
          # u.shape          = (*batch_shape, num_pieces)
          # gamma.shape      = (*batch_shape, 1)
          # other_para.shape = (*batch_shape, 1, num_pieces)
  
          gamma = self.gamma.unsqueeze(dim=0 if dim == 0 else -1)
          knot_positions, b = (
              self.knot_positions.unsqueeze(dim=dim),
              self.b.unsqueeze(dim=dim),
          )
      else:
          # when num_sample is None
          #
          # In testing
          # dim = None
          # u.shape          = (*batch_shape)
          # gamma.shape      = (*batch_shape)
          # other_para.shape = (*batch_shape, num_pieces)
  
          gamma = self.gamma
          knot_positions, b = self.knot_positions, self.b
  
      u = u.unsqueeze(-1)
      u_spline = F.relu(u - knot_positions)
      quantile = gamma + torch.sum(b * u_spline, dim=-1)
  
      return quantile
  
imports: from typing import Dict, List, Optional, Tuple, cast
  import torch
  import torch.nn.functional
  from torch.distributions import AffineTransform, TransformedDistribution
  from gluonts.core.component import validated
  from .distribution_output import DistributionOutput
label_desc: Use image node_id 5 for calling the PiecewiseLinear obj's underlying member method code with example usage: obj.quantile_internal(u, dim) and returns: quantile