code: def get_bucket(conn, bucket_name):
      """A helper to get a bucket
  
      Parameters
      ----------
      bucket_name: str
          Name of the bucket to connect to
      """
      try:
          return try_multiple_dec_s3(conn.get_bucket)(bucket_name)
      except S3ResponseError as e:
          ce = CapturedException(e)
          # can initially deny or error to connect to the specific bucket by name,
          # and we would need to list which buckets are available under following
          # credentials:
          lgr.debug(
              "Cannot access bucket %s by name with validation: %s",
              bucket_name,
              ce,
          )
          if conn.anon:
              raise AnonymousAccessDeniedError(
                  "Access to the bucket %s did not succeed.  Requesting "
                  "'all buckets' for anonymous S3 connection makes "
                  "little sense and thus not supported." % bucket_name,
                  supported_types=["aws-s3"],
              )
  
          if e.reason == "Forbidden":
              # Could be just HEAD call boto issues is not allowed, and we should not
              # try to verify that bucket is "reachable".  Just carry on
              try:
                  return try_multiple_dec_s3(conn.get_bucket)(
                      bucket_name, validate=False
                  )
              except S3ResponseError as e2:
                  lgr.debug(
                      "Cannot access bucket %s even without validation: %s",
                      bucket_name,
                      CapturedException(e2),
                  )
                  _handle_exception(e, bucket_name)
  
          try:
              all_buckets = try_multiple_dec_s3(conn.get_all_buckets)()
              all_bucket_names = [b.name for b in all_buckets]
              lgr.debug(
                  "Found following buckets %s",
                  ", ".join(all_bucket_names),
              )
              if bucket_name in all_bucket_names:
                  return all_buckets[
                      all_bucket_names.index(bucket_name)
                  ]
          except S3ResponseError as e2:
              lgr.debug(
                  "Cannot access all buckets: %s", CapturedException(e2)
              )
              _handle_exception(
                  e, "any (originally requested %s)" % bucket_name
              )
          else:
              _handle_exception(e, bucket_name)
  
imports: import mimetypes
  from os.path import splitext
  import re
  from datalad.support.network import urlquote, URL
  import logging
  import datalad.log
  from datalad.support.exceptions import CapturedException, DownloadError, AccessDeniedError, AccessPermissionExpiredError, AnonymousAccessDeniedError
  from datalad.utils import try_multiple_dec
  from urllib.request import urlopen, Request
label_desc: Use image node_id 5 for calling a global function with example usage: get_bucket(conn, bucket_name) and returns: try_multiple_dec_s3, try_multiple_dec_s3, all_buckets