code: def download_image(
      url: str,
      session: requests.Session = None,
      retry_fn: Callable = utils.retry,
      request_kwargs: Optional[Dict] = None,
  ) -> PIL.Image.Image:
      """Downloads an image from a url.
  
      Args:
          url:
              The url where the image is downloaded from.
          session:
              Session object to persist certain parameters across requests.
          retry_fn:
              Retry function that handles failed downloads.
          request_kwargs:
              Additional parameters passed to requests.get().
  
      Returns:
          The downloaded image.
  
      """
      request_kwargs = request_kwargs or {}
      request_kwargs.setdefault("stream", True)
      request_kwargs.setdefault("timeout", 10)
  
      def load_image(url, req, request_kwargs):
          with req.get(url=url, **request_kwargs) as response:
              response.raise_for_status()
              image = PIL.Image.open(response.raw)
              image.load()
          return image
  
      req = requests if session is None else session
      image = retry_fn(load_image, url, req, request_kwargs)
      return image
  
file_path: lightly/lightly/api/download.py
imports: import concurrent.futures
  import os
  import pathlib
  import shutil
  import threading
  import warnings
  from concurrent.futures import ThreadPoolExecutor
  from typing import Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
  import PIL
  import requests
  import tqdm
  from lightly.api import utils
label_desc: Use image node_id 2 for calling a global function with example usage: download_image(url, session, retry_fn, request_kwargs) and returns: image, image