code: def check_events(events):
      """Test that the events data describes a valid experimental paradigm.
  
      It is valid if the events data has ``'onset'`` and ``'duration'`` keys
      with numeric non NaN values.
  
      Parameters
      ----------
      events : pandas DataFrame
          Events data that describes a functional experimental paradigm.
  
      Returns
      -------
      events : pandas DataFrame
          Events data that describes a functional experimental paradigm.
  
      The dataframe has the following columns:
  
      trial_type : array of shape (n_events,), dtype='s'
          Per-event experimental conditions identifier.
          Defaults to np.repeat('dummy', len(onsets)).
  
      onset : array of shape (n_events,), dtype='f'
          Per-event onset time (in seconds)
  
      duration : array of shape (n_events,), dtype='f'
          Per-event durantion, (in seconds)
          defaults to zeros(n_events) when no duration is provided
  
      modulation : array of shape (n_events,), dtype='f'
          Per-event modulation, (in seconds)
          defaults to ones(n_events) when no duration is provided.
  
      Raises
      ------
      TypeError
          If the events data is not a pandas DataFrame.
  
      ValueError
          If the events data has:
  
              - no ``'onset'`` or ``'duration'`` column,
              - has non numeric values
                in the ``'onset'`` or ``'duration'`` columns
              - has nan values in the ``'onset'`` or ``'duration'`` columns.
  
      Warns
      -----
      UserWarning
          If the events data:
  
              - has no ``'trial_type'`` column,
              - has any event with a duration equal to 0,
              - contains columns other than ``'onset'``, ``'duration'``,
                ``'trial_type'`` or ``'modulation'``,
              - contains duplicated events, meaning event with same:
  
                  - ``'trial_type'``
                  - ``'onset'``
                  - ``'duration'``
  
      """
      # Check that events is a Pandas DataFrame
      if not isinstance(events, pd.DataFrame):
          raise TypeError(
              "Events should be a Pandas DataFrame. "
              f"A {type(events)} was provided instead."
          )
  
      events = _check_columns(events)
  
      events_copy = events.copy()
  
      events_copy = _handle_missing_trial_types(events_copy)
  
      _check_null_duration(events_copy)
  
      _check_unexpected_columns(events_copy)
  
      return _handle_modulation(events_copy)
  
file_path: nilearn/nilearn/glm/first_level/experimental_paradigm.py
imports: import warnings
  import pandas
  from pandas.api.types import is_numeric_dtype
label_desc: Use image node_id 1 for calling a global function with example usage: check_events(events) and returns: _handle_modulation