code: def check_window_length(
      window_length: ACCEPTED_WINDOW_LENGTH_TYPES,
      n_timepoints: int = None,
      name: str = "window_length",
  ) -> NON_FLOAT_WINDOW_LENGTH_TYPES:
      """Validate window length.
  
      Parameters
      ----------
      window_length: positive int, positive float in (0, 1), positive timedelta,
          positive pd.DateOffset, or None
          The window length:
          - If int, the total number of time points.
          - If float, the fraction of time points relative to `n_timepoints`.
          - If timedelta, length in corresponding time units
          - If pd.DateOffset, length in corresponding time units following calendar rules
      n_timepoints: positive int, optional (default=None)
          The number of time points to which to apply `window_length` when
          passed as a float (fraction). Will be ignored if `window_length` is
          an integer.
      name: str
          Name of argument for error messages.
  
      Returns
      -------
      window_length: int or timedelta or pd.DateOffset
      """
      if window_length is None:
          return window_length
  
      elif is_int(window_length) and window_length >= 0:
          return window_length
  
      elif is_float(window_length) and 0 < window_length < 1:
          # Check `n_timepoints`.
          if not is_int(n_timepoints) or n_timepoints < 2:
              raise ValueError(
                  f"`n_timepoints` must be a positive integer, but found:"
                  f" {n_timepoints}."
              )
  
          # Compute fraction relative to `n_timepoints`.
          return int(np.ceil(window_length * n_timepoints))
  
      elif is_timedelta(window_length) and window_length > timedelta(0):
          return window_length
  
      elif is_date_offset(window_length) and pd.Timestamp(
          0
      ) + window_length > pd.Timestamp(0):
          return window_length
  
      else:
          raise ValueError(
              f"`{name}` must be a positive integer >= 0, or "
              f"float in (0, 1) or None, but found: {window_length}."
          )
  
imports: import os
  from datetime import timedelta
  from typing import Union
  import numpy
  import pandas
label_desc: Use image node_id 17 for calling a global function with example usage: check_window_length(window_length, n_timepoints, name) and returns: window_length, window_length, int, window_length, window_length