code: def download_image(row):
      fname = _file_name(row)
      # Skip Already downloaded, retry others later
      if os.path.isfile(fname):
          row["status"] = 200
          row["file"] = fname
          row["mimetype"] = magic.from_file(row["file"], mime=True)
          row["size"] = os.stat(row["file"]).st_size
          return row
  
      try:
          # use smaller timeout to skip errors, but can result in failed downloads
          response = requests.get(
              row["url"],
              stream=False,
              timeout=5,
              allow_redirects=True,
              headers=headers,
          )
          row["status"] = response.status_code
          # row['headers'] = dict(response.headers)
      except Exception as e:
          # log errors later, set error as 408 timeout
          row["status"] = 408
          return row
  
      if response.ok:
          try:
              # some sites respond with gzip transport encoding
              response.raw.decode_content = True
              img = resize_img(io.BytesIO(response.content))
              img.save(fname)
  
              row["mimetype"] = magic.from_file(fname, mime=True)
              row["size"] = os.stat(fname).st_size
  
          except Exception as e:
              #     # This is if it times out during a download or decode
              row["status"] = 408
  
      row["file"] = fname
      return row
  
imports: import glob
  from pathlib import Path
  import time
  from omegaconf import OmegaConf
  import pandas
  import numpy
  import requests
  import zlib
  import os
  import io
  import shelve
  from lavis.common.utils import get_abs_path, get_cache_path
  import magic
  import json
  from multiprocessing import Pool
  from tqdm import tqdm
  from PIL import Image
  from torchvision.transforms import functional
label_desc: Use image node_id 7 for calling a global function with example usage: download_image(row) and returns: row, row, row