code: def _find_end_indices(
      diffs: np.ndarray, max_lengths: np.ndarray, min_length: int
  ) -> Tuple[np.ndarray, np.ndarray]:
      """
      Identify end indices in series even if some values are missing.
  
      Args:
          diffs (np.ndarray): array of differences to next time step. nans should be filled up with ones
          max_lengths (np.ndarray): maximum length of sequence by position.
          min_length (int): minimum length of sequence.
  
      Returns:
          Tuple[np.ndarray, np.ndarray]: tuple of arrays where first is end indices and second is list of start
              and end indices that are currently missing.
      """
      missing_start_ends = []
      end_indices = []
      length = 1
      start_idx = 0
      max_idx = len(diffs) - 1
      max_length = max_lengths[start_idx]
  
      for idx, diff in enumerate(diffs):
          if length >= max_length:
              while length >= max_length:
                  if length == max_length:
                      end_indices.append(idx)
                  else:
                      end_indices.append(idx - 1)
                  length -= diffs[start_idx]
                  if start_idx < max_idx:
                      start_idx += 1
                  max_length = max_lengths[start_idx]
          elif length >= min_length:
              missing_start_ends.append([start_idx, idx])
          length += diff
      if len(missing_start_ends) > 0:  # required for numba compliance
          return np.asarray(end_indices), np.asarray(missing_start_ends)
      else:
          return np.asarray(end_indices), np.empty(
              (0, 2), dtype=np.int64
          )
  
imports: from copy import copy, deepcopy
  from functools import lru_cache
  import inspect
  from typing import Any, Callable, Dict, List, Tuple, Union
  import warnings
  import matplotlib.pyplot
  import numpy
  import pandas
  from sklearn.exceptions import NotFittedError
  from sklearn.preprocessing import RobustScaler, StandardScaler
  from sklearn.utils.validation import check_is_fitted
  import torch
  from torch.distributions import Beta
  from torch.nn.utils import rnn
  from torch.utils.data import DataLoader, Dataset
  from torch.utils.data.sampler import Sampler, SequentialSampler
  from pytorch_forecasting.data.encoders import EncoderNormalizer, GroupNormalizer, MultiNormalizer, NaNLabelEncoder, TorchNormalizer
  from pytorch_forecasting.data.samplers import TimeSynchronizedBatchSampler
  from pytorch_forecasting.utils import repr_class
label_desc: Use image node_id 1 for calling a global function with example usage: _find_end_indices(diffs, max_lengths, min_length) and returns: np,  np, np,  np