code: def _check_time_format(time_format, valid, meas_date=None):
      """Check time_format argument."""
      if time_format not in valid and time_format is not None:
          valid_str = '", "'.join(valid)
          raise ValueError(
              f'"{time_format}" is not a valid time format. Valid options are '
              f'"{valid_str}" and None.'
          )
      # allow datetime only if meas_date available
      if time_format == "datetime" and meas_date is None:
          warn(
              "Cannot convert to Datetime when raw.info['meas_date'] is "
              "None. Falling back to Timedelta."
          )
          time_format = "timedelta"
      return time_format
  
imports: import numbers
  import operator
  import os
  import re
  from builtins import input
  from difflib import get_close_matches
  from importlib import import_module
  from pathlib import Path
  import numpy
  from ..defaults import HEAD_SIZE_DEFAULT, _handle_default
  from ..fixes import _compare_version, _median_complex
  from ._logging import _record_warnings, _verbose_safe_false, logger, verbose, warn
label_desc: Use image node_id 23 for calling a global function with example usage: _check_time_format(time_format, valid, meas_date) and returns: time_format