docstr: This method overrides the method from the PiecewiseLinear class.
docstr_tok: ["This","method","overrides","the","method","from","the","PiecewiseLinear","class","."]
code: def compute_k_t(
      self,
      current_segment,
      past_next_changepoint,
      meta_name_tensor_one_hot,
  ):
      """This method overrides the method from the PiecewiseLinear class."""
      # For segmentwise k_t, is the model parameter representing the trend slope(actually, trend slope-k_0) in the
      # current_segment at time t (for each sample of the batch).
      # k_t = k_t(current_segment, sample metadata)
      # dimensions - quantiles, batch_size, segments (+ 1)
      trend_deltas_by_sample = torch.sum(
          meta_name_tensor_one_hot.unsqueeze(dim=0).unsqueeze(dim=-1)
          * self.trend_deltas.unsqueeze(dim=1),
          dim=2,
      )
      # dimensions - batch_size, n_forecasts, quantiles_size
      k_t = torch.sum(
          current_segment.unsqueeze(dim=2)
          * trend_deltas_by_sample.permute(1, 0, 2).unsqueeze(1),
          dim=-1,
      )
  
      # For not segmentwise k_t is the model parameter representing the difference between trend slope in the
      # current_segment at time t and the trend slope in the previous segment (for each sample of the batch).
      if not self.segmentwise_trend:
          # k_t = k_t(current_segment, previous_segment, sample metadata)
          previous_deltas_t = torch.sum(
              past_next_changepoint.unsqueeze(dim=2)
              * trend_deltas_by_sample.permute(1, 0, 2)[
                  :, :, :-1
              ].unsqueeze(dim=1),
              dim=-1,
          )
          # dimensions - batch_size, n_forecasts, quantiles_size
          k_t = k_t + previous_deltas_t
  
      return k_t
  
imports: import numpy
  import torch
  import torch.nn
  from neuralprophet.components.trend import Trend
  from neuralprophet.utils_torch import init_parameter
label_desc: Use image node_id 2 for calling the LocalPiecewiseLinearTrend obj's underlying member method code with example usage: obj.compute_k_t(current_segment, past_next_changepoint, meta_name_tensor_one_hot) and returns: k_t