code: def train_step_from_batch(
      ts_chunks: torch.Tensor,
      targets: torch.Tensor,
      distr_tcn: DistributionalTCN,
      optimizer: torch.optim.Adam,
  ):
      """
      Arguments
      ----------
      ts_chunks: Mini-batch chunked from the time series
      targets: Corresponding chunk of target values
      distr_tcn: DistributionalTCN
      otimizer: Optimizer containing parameters, learning rate, etc
      """
      distr_outputs = distr_tcn(ts_chunks.float())
      loss = -distr_outputs.log_prob(targets.float())
      loss = loss.mean()
      loss_value = loss.cpu().detach().numpy()
      loss.backward()
      optimizer.step()
      return loss_value
  
file_path: gluonts/src/gluonts/nursery/spliced_binned_pareto/training_functions.py
imports: from typing import Optional
  import matplotlib
  import matplotlib.pyplot
  import numpy
  import pandas
  import torch.nn
  import torch.optim
  from .distr_tcn import DistributionalTCN
label_desc: Use image node_id 1 for calling a global function with example usage: train_step_from_batch(ts_chunks, targets, distr_tcn, optimizer) and returns: loss_value