code: def _download_and_replace_images(
      self,
      html_soup,
      resources,
      output_folder,
      relative_to,
      notebook_path,
      get_image_from_local=False,
  ):
      output_folder = output_folder.replace("/", os.sep)
      os.makedirs(output_folder, exist_ok=True)
  
      if resources:
          # resources converted from notebook
          resources_img, i = [], 0
          for img_filename, content in resources.get(
              "outputs", {}
          ).items():
              img_path = os.path.join(
                  output_folder, img_filename.replace("_", "-")
              )
              with open(img_path, "wb") as img_file:
                  img_file.write(content)
              img_path_rel = os.path.relpath(
                  img_path, relative_to
              ).replace(os.sep, "/")
              resources_img.append(img_path_rel)
  
      img_tags = html_soup.find_all("img")
      for img_tag in img_tags:
          img_loc = img_tag["src"]
  
          if self._is_valid_url(img_loc):
              # downloaded image
              response = requests.get(img_loc)
              if response.status_code == 200:
                  img_filename = self._sentence_to_snake(
                      img_loc.split("/")[-1]
                  )
                  img_path = os.path.join(output_folder, img_filename)
                  with open(img_path, "wb") as img_file:
                      img_file.write(response.content)
                  img_path_rel = os.path.relpath(
                      img_path, relative_to
                  ).replace(os.sep, "/")
                  img_tag["src"] = img_path_rel
              else:
                  raise ValueError(
                      f"Could not download image from {img_loc}"
                  )
  
          elif get_image_from_local:
              # process local images
              img_filename = self._sentence_to_snake(
                  img_loc.split("/")[-1]
              ).replace("_", "-")
              file_folder = "/".join(
                  notebook_path.split("/")[:-1]
              )  # path read from manifest file
              img_input_path = os.path.join(
                  self.input_dir, file_folder, img_loc
              ).replace("/", os.sep)
              if not os.path.exists(img_input_path):
                  raise ValueError(
                      f"Could not get image from {img_loc}"
                  )
              img_path = os.path.join(output_folder, img_filename)
              img_path_rel = os.path.relpath(
                  img_path, relative_to
              ).replace(os.sep, "/")
              shutil.copy(img_input_path, img_path)
  
          else:
              # process image got from notebook resources
              img_path_rel = resources_img[i]
              img_tag["src"] = img_path_rel
              i += 1
  
          self._replace_img_tag(img_tag, img_path_rel)
  
      return html_soup
  
imports: import os
  import pathlib
  import re
  import shutil
  import warnings
  from datetime import datetime
  from os.path import basename, dirname
  from typing import List
  from urllib.parse import urlparse
  import markdown
  import pypandoc
  import requests
  from bs4 import BeautifulSoup
  from docgen.core import Channel, ParallelChannel
  from markdownify import ATX, MarkdownConverter
  from nbconvert import MarkdownExporter
  from nbformat import read
  from traitlets.config import Config
label_desc: Use image node_id 6 for calling the FabricChannel obj's underlying member method code with example usage: obj._download_and_replace_images(html_soup, resources, output_folder, relative_to, notebook_path, get_image_from_local) and returns: html_soup