code: def _extract_file_content(
      file_path: str,
      message: str | None,
      pattern: str,
      expected_contain: bool,
  ):
      if not message:
          message = f"Pattern '{pattern}' could not be found in '{file_path}' file."
      with open(file_path, "rb", 0) as doc_file:
          pattern_compiled = re.compile(pattern)
          found = False
          for num, line in enumerate(doc_file, 1):
              line_decode = line.decode()
              result = re.search(pattern_compiled, line_decode)
              if not expected_contain and result:
                  return DocBuildError(
                      file_path=file_path, line_no=num, message=message
                  )
              elif expected_contain and result:
                  found = True
  
          if expected_contain and not found:
              return DocBuildError(
                  file_path=file_path, line_no=None, message=message
              )
      return None
  
imports: from __future__ import annotations
  import ast
  import itertools
  import os
  import re
  from glob import glob
  from typing import Iterable
  from docs.exts.docs_build.docs_builder import ALL_PROVIDER_YAMLS
  from docs.exts.docs_build.errors import DocBuildError
label_desc: Use image node_id 8 for calling a global function with example usage: _extract_file_content(file_path, message, pattern, expected_contain) and returns: None, DocBuildError, DocBuildError