code: def download(self, f=None, pbar=None, size=None):
      # S3 specific (the rest is common with e.g. http)
      def pbar_callback(downloaded, totalsize):
          assert totalsize == self.key.size
          if pbar:
              try:
                  pbar.update(downloaded)
              except:  # MIH: what does it do? MemoryError?
                  pass  # do not let pbar spoil our fun
  
      headers = {}
      # report for every % for files > 10MB, otherwise every 10%
      kwargs = dict(
          headers=headers,
          cb=pbar_callback,
          num_cb=100 if self.key.size > 10 * (1024**2) else 10,
      )
      if size:
          headers["Range"] = "bytes=0-%d" % (size - 1)
      if f:
          # TODO: May be we could use If-Modified-Since
          # see http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html
          self.key.get_contents_to_file(f, **kwargs)
      else:
          return self.key.get_contents_as_string(
              encoding=None, **kwargs
          )
  
imports: import re
  from urllib.parse import urlsplit, unquote
  from ..utils import auto_repr, ensure_dict_from_str
  from ..dochelpers import borrowkwargs
  from ..support.network import get_url_straight_filename, iso8601_to_epoch, rfc2822_to_epoch
  from .base import Authenticator
  from .base import BaseDownloader, DownloaderSession
  from ..support.exceptions import AccessPermissionExpiredError, CapturedException, TargetFileAbsent
  from ..support.s3 import Key, OrdinaryCallingFormat, S3ResponseError, boto, get_bucket, try_multiple_dec_s3
  from ..support.status import FileStatus
  import logging
  from logging import getLogger
label_desc: Use image node_id 2 for calling the S3DownloaderSession obj's underlying member method code with example usage: obj.download(f, pbar, size) and returns: self