code: def latest_inputs_and_outputs(
      path, fmt, formats, get_timestamp, contents_manager_mode=False
  ):
      """Given a notebook path, its format and paired formats, and a function that
      returns the timestamp for each (or None if the file does not exist), return
      the most recent notebook for the inputs and outputs, respectively
      """
  
      timestamp_inputs = None
      timestamp_outputs = None
      inputs_path = None
      outputs_path = None
      input_fmt = None
      output_fmt = None
  
      fmt = long_form_one_format(fmt)
      formats = long_form_multiple_formats(formats)
  
      for alt_path, alt_fmt in paired_paths(path, fmt, formats):
          # In the contents manager, we don't read another text file if the current notebook is in already in text mode
          if (
              contents_manager_mode
              and alt_fmt["extension"] != ".ipynb"
              and fmt["extension"] != ".ipynb"
          ):
              if any(
                  alt_fmt.get(key) != fmt.get(key)
                  for key in ["extension", "suffix", "prefix"]
              ):
                  continue
  
          timestamp = get_timestamp(alt_path)
          if timestamp is None:
              continue
  
          if alt_fmt["extension"] == ".ipynb":
              if (
                  timestamp_outputs is None
                  or timestamp > timestamp_outputs
              ):
                  timestamp_outputs = timestamp
                  outputs_path, output_fmt = alt_path, alt_fmt
          elif timestamp_inputs is None or timestamp > timestamp_inputs:
              timestamp_inputs = timestamp
              inputs_path, input_fmt = alt_path, alt_fmt
  
      if timestamp_inputs is None or (
          not contents_manager_mode
          and timestamp_outputs
          and timestamp_outputs > timestamp_inputs
      ):
          timestamp_inputs = timestamp_outputs
          inputs_path, input_fmt = outputs_path, output_fmt
  
      return (
          NotebookFile(inputs_path, input_fmt, timestamp_inputs),
          NotebookFile(outputs_path, output_fmt, timestamp_outputs),
      )
  
file_path: jupytext/src/jupytext/pairs.py
imports: from collections import namedtuple
  import jupytext
  from .combine import combine_inputs_with_outputs
  from .compare import compare
  from .formats import check_file_version, long_form_multiple_formats, long_form_one_format
  from .paired_paths import find_base_path_and_format, full_path, paired_paths
label_desc: Use image node_id 2 for calling a global function with example usage: latest_inputs_and_outputs(path, fmt, formats, get_timestamp, contents_manager_mode) and returns: NotebookFile,  NotebookFile