code: def _make_dirs(filepath, mode):
      """
      If writing ``filepath`` to a directory that doesn't exist, all intermediate
      directories will be created as needed.
      """
      parent = filepath.parent
      if "w" in mode and parent:
          os.makedirs(parent, exist_ok=True)
  
imports: from __future__ import annotations
  import bz2
  import gzip
  import io
  import itertools
  import logging
  import lzma
  import os
  import re
  import shutil
  import tarfile
  import urllib
  import zipfile
  from typing import IO, Iterable, Literal, Optional
  from cytoolz import itertoolz
  from ..None import constants
  from ..None import errors
  from ..None import types, utils
  from .http import write_http_stream
label_desc: Use image node_id 4 for calling a global function with example usage: _make_dirs(filepath, mode) without return types