code: def get_top_level_folders_in_bucket(s3client, bucket_name):
      # This function returns the top level folders in the S3Bucket.
      # These folders help us to navigate to the trained model files stored for different MXNet versions.
      bucket = s3client.Bucket(bucket_name)
      result = bucket.meta.client.list_objects(
          Bucket=bucket.name, Delimiter=backslash
      )
      folder_list = list()
      if "CommonPrefixes" not in result:
          logging.error(
              "No trained models found in S3 bucket : {} for this file. "
              "Please train the models and run inference again".format(
                  bucket_name
              )
          )
          raise Exception(
              "No trained models found in S3 bucket : {} for this file. "
              "Please train the models and run inference again".format(
                  bucket_name
              )
          )
          return folder_list
      for obj in result["CommonPrefixes"]:
          folder_name = obj["Prefix"].strip(backslash)
          # We only compare models from the same major versions. i.e. 1.x.x compared with latest 1.y.y etc
          if (
              str(folder_name).split(".")[0]
              != str(mxnet_version).split(".")[0]
          ):
              continue
          # The top level folders contain MXNet Version # for trained models. Skipping the data folder here
          if folder_name == data_folder:
              continue
          folder_list.append(obj["Prefix"].strip(backslash))
  
      if len(folder_list) == 0:
          logging.error(
              "No trained models found in S3 bucket : {} for this file. "
              "Please train the models and run inference again".format(
                  bucket_name
              )
          )
          raise Exception(
              "No trained models found in S3 bucket : {} for this file. "
              "Please train the models and run inference again".format(
                  bucket_name
              )
          )
      return folder_list
  
imports: import boto3
  import mxnet
  import os
  import numpy
  import logging
  from mxnet import gluon
  from mxnet.gluon import nn
  import re
  from mxnet.test_utils import assert_almost_equal
label_desc: Use image node_id 8 for calling a global function with example usage: get_top_level_folders_in_bucket(s3client, bucket_name) and returns: folder_list, folder_list