def _list_profile_filter(
    profile_datum, node_name_regex, file_name_regex, op_type_regex,
    op_time_interval, exec_time_interval):
  """Filter function for list_profile command.

  Args:
    profile_datum: A `ProfileDatum` object.
    node_name_regex: Regular expression pattern object to filter by name.
    file_name_regex: Regular expression pattern object to filter by file.
    op_type_regex: Regular expression pattern object to filter by op type.
    op_time_interval: `Interval` for filtering op time.
    exec_time_interval: `Interval` for filtering exec time.

  Returns:
    True if profile_datum should be included.
  """
  if not node_name_regex.match(
      profile_datum.node_exec_stats.node_name):
    return False
  if profile_datum.file_line is not None and not file_name_regex.match(
      profile_datum.file_line):
    return False
  if profile_datum.op_type is not None and not op_type_regex.match(
      profile_datum.op_type):
    return False
  if op_time_interval is not None and not op_time_interval.contains(
      profile_datum.op_time):
    return False
  if exec_time_interval and not exec_time_interval.contains(
      profile_datum.node_exec_stats.all_end_rel_micros):
    return False
  return True