docstr: Computes the negative log likelihood loss for the given sequences.
  
  As the model is trained on past (resp. future) or context
  (resp. prediction) "intervals" as opposed to fixed-length "sequences",
  the number of data points available varies across observations. To
  account for this, data is made available to the training network as a
  "ragged" tensor. The number of valid entries in each sequence is
  provided in a separate variable, :code:`xxx_valid_length`.
  
  Parameters
  ----------
  F
      MXNet backend.
  target
      Tensor with observations.
      Shape: (batch_size, past_max_sequence_length, target_dim).
  valid_length
      The `valid_length` or number of valid entries in the past_target
      Tensor. Shape: (batch_size,)
  
  Returns
  -------
  Tensor
      Loss tensor. Shape: (batch_size,).
docstr_tok: ["Computes","the","negative","log","likelihood","loss","for","the","given","sequences",".","As","the","model","is","trained","on","past","(","resp",".","future",")","or","context","(","resp",".","prediction",")","``","intervals","''","as","opposed","to","fixed-length","``","sequences","''",",","the","number","of","data","points","available","varies","across","observations",".","To","account","for","this",",","data","is","made","available","to","the","training","network","as","a","''","ragged","''","tensor",".","The","number","of","valid","entries","in","each","sequence","is","provided","in","a","separate","variable",",",":","code",":","`","xxx_valid_length","`",".","Parameters","--","--","--","--","--","F","MXNet","backend",".","target","Tensor","with","observations",".","Shape",":","(","batch_size",",","past_max_sequence_length",",","target_dim",")",".","valid_length","The","`","valid_length","`","or","number","of","valid","entries","in","the","past_target","Tensor",".","Shape",":","(","batch_size",",",")","Returns","--","--","--","-","Tensor","Loss","tensor",".","Shape",":","(","batch_size",",",")","."]
code: def hybrid_forward(
      self,
      F,
      target: Tensor,
      valid_length: Tensor,
      **kwargs,
  ) -> Tensor:
      """
      Computes the negative log likelihood loss for the given sequences.
  
      As the model is trained on past (resp. future) or context
      (resp. prediction) "intervals" as opposed to fixed-length "sequences",
      the number of data points available varies across observations. To
      account for this, data is made available to the training network as a
      "ragged" tensor. The number of valid entries in each sequence is
      provided in a separate variable, :code:`xxx_valid_length`.
  
      Parameters
      ----------
      F
          MXNet backend.
      target
          Tensor with observations.
          Shape: (batch_size, past_max_sequence_length, target_dim).
      valid_length
          The `valid_length` or number of valid entries in the past_target
          Tensor. Shape: (batch_size,)
  
      Returns
      -------
      Tensor
          Loss tensor. Shape: (batch_size,).
      """
      if F is mx.sym:
          raise ValueError(
              "The DeepTPP model currently doesn't support hybridization."
          )
  
      batch_size = target.shape[0]
      # IMPORTANT: We add an additional zero at the end of each sequence
      # It will be used to store the time until the end of the interval
      target = F.concat(target, F.zeros((batch_size, 1, 2)), dim=1)
      # (N, T + 1, 2)
  
      ia_times, marks = F.split(
          target, num_outputs=2, axis=-1
      )  # inter-arrival times, marks
      marks = marks.squeeze(axis=-1)  # (N, T + 1)
  
      valid_length = valid_length.reshape(-1).astype(
          ia_times.dtype
      )  # make sure shape is (batch_size,)
  
      if self.apply_log_to_rnn_inputs:
          ia_times_input = ia_times.clip(1e-8, np.inf).log()
      else:
          ia_times_input = ia_times
      rnn_input = F.concat(
          ia_times_input, self.embedding(marks), dim=-1
      )
      rnn_output = self.rnn(rnn_input)  # (N, T + 1, H)
  
      rnn_init_state = F.zeros([batch_size, 1, self.rnn_hidden_size])
      history_emb = F.slice_axis(
          F.concat(rnn_init_state, rnn_output, dim=1),
          axis=1,
          begin=0,
          end=-1,
      )  # (N, T + 1, H)
  
      # Augment ia_times by adding the time remaining until interval_length
      # Afterwards, each row of ia_times will sum up to interval_length
      ia_times = ia_times.squeeze(axis=-1)  # (N, T + 1)
      time_remaining = self.interval_length - ia_times.sum(-1)  # (N)
      # Equivalent to ia_times[F.arange(N), valid_length] = time_remaining
      indices = F.stack(F.arange(batch_size), valid_length)
      time_remaining_tensor = F.scatter_nd(
          time_remaining, indices, ia_times.shape
      )
      ia_times_aug = ia_times + time_remaining_tensor
  
      time_distr_args = self.time_distr_args_proj(history_emb)
      time_distr = self.time_distr_output.distribution(
          time_distr_args, scale=self.output_scale
      )
      log_intensity = time_distr.log_intensity(
          ia_times_aug
      )  # (N, T + 1)
      log_survival = time_distr.log_survival(ia_times_aug)  # (N, T + 1)
  
      if self.num_marks > 1:
          mark_distr_args = self.mark_distr_args_proj(history_emb)
          mark_distr = self.mark_distr_output.distribution(
              mark_distr_args
          )
          log_intensity = log_intensity + mark_distr.log_prob(marks)
  
      def _mask(x, sequence_length):
          return F.SequenceMask(
              data=x,
              sequence_length=sequence_length,
              axis=1,
              use_sequence_length=True,
          )
  
      log_likelihood = F.sum(
          (
              _mask(log_intensity, valid_length)
              + _mask(log_survival, valid_length + 1)
          ),
          axis=-1,
      )  # (N)
  
      return -log_likelihood
  
file_path: gluonts/src/gluonts/mx/model/tpp/deeptpp/_network.py
imports: from typing import List, Optional, Tuple
  import mxnet
  import numpy
  from mxnet import nd
  from gluonts.core.component import validated
  from gluonts.mx.model.tpp import distribution
  from gluonts.mx.model.tpp.distribution.base import TPPDistributionOutput
  from gluonts.mx import Tensor
  from gluonts.mx.distribution import CategoricalOutput
label_desc: Use image node_id 1 for calling the DeepTPPTrainingNetwork obj's underlying member method code with example usage: obj.hybrid_forward(F, target, valid_length) and returns: unknown, F