docstr: Trim temporal information from a dataset.
  Returns temporal indexes [t+left:t-right] for all series.
docstr_tok: ["Trim","temporal","information","from","a","dataset",".","Returns","temporal","indexes","[","t+left",":","t-right","]","for","all","series","."]
code: def trim_dataset(dataset, left_trim: int = 0, right_trim: int = 0):
      """
      Trim temporal information from a dataset.
      Returns temporal indexes [t+left:t-right] for all series.
      """
      if dataset.min_size <= left_trim + right_trim:
          raise Exception(
              f"left_trim + right_trim ({left_trim} + {right_trim}) \
                                  must be lower than the shorter time series ({dataset.min_size})"
          )
  
      # Define and fill new temporal with trimmed information
      len_temporal, col_temporal = dataset.temporal.shape
      total_trim = (left_trim + right_trim) * dataset.n_groups
      new_temporal = torch.zeros(
          size=(len_temporal - total_trim, col_temporal)
      )
      new_indptr = [0]
  
      acum = 0
      for i in range(dataset.n_groups):
          series_length = dataset.indptr[i + 1] - dataset.indptr[i]
          new_length = series_length - left_trim - right_trim
          new_temporal[
              acum : (acum + new_length), :
          ] = dataset.temporal[
              dataset.indptr[i]
              + left_trim : dataset.indptr[i + 1]
              - right_trim,
              :,
          ]
          acum += new_length
          new_indptr.append(acum)
  
      new_max_size = dataset.max_size - left_trim - right_trim
      new_min_size = dataset.min_size - left_trim - right_trim
  
      # Define new dataset
      updated_dataset = TimeSeriesDataset(
          temporal=new_temporal,
          temporal_cols=dataset.temporal_cols.copy(),
          indptr=np.array(new_indptr).astype(np.int32),
          max_size=new_max_size,
          min_size=new_min_size,
          y_idx=dataset.y_idx,
          static=dataset.static,
          static_cols=dataset.static_cols,
          sorted=dataset.sorted,
      )
  
      return updated_dataset
  
imports: import warnings
  from collections.abc import Mapping
  import numpy
  import pandas
  import pytorch_lightning
  import torch
  import utilsforecast.processing
  from torch.utils.data import Dataset, DataLoader
  from utilsforecast.compat import DataFrame, pl_Series
label_desc: Use image node_id 9 for calling the TimeSeriesDataset obj's underlying member method code with example usage: obj.trim_dataset(dataset, left_trim, right_trim) and returns: updated_dataset