code: def _make_download_config(
      args: argparse.Namespace,
      dataset_name: str,
  ) -> tfds.download.DownloadConfig:
      """Generate the download and prepare configuration."""
      # Load the download config
      manual_dir = args.manual_dir
      if args.add_name_to_manual_dir:
          manual_dir = os.path.join(manual_dir, dataset_name)
  
      kwargs = {}
      if args.max_shard_size_mb:
          kwargs["max_shard_size"] = args.max_shard_size_mb << 20
      if args.download_config:
          kwargs.update(json.loads(args.download_config))
  
      if "download_mode" in kwargs:
          kwargs["download_mode"] = tfds.download.GenerateMode(
              kwargs["download_mode"]
          )
      else:
          kwargs[
              "download_mode"
          ] = tfds.download.GenerateMode.REUSE_DATASET_IF_EXISTS
      if args.update_metadata_only:
          kwargs[
              "download_mode"
          ] = tfds.download.GenerateMode.UPDATE_DATASET_INFO
  
      dl_config = tfds.download.DownloadConfig(
          extract_dir=args.extract_dir,
          manual_dir=manual_dir,
          max_examples_per_split=args.max_examples_per_split,
          register_checksums=args.register_checksums,
          force_checksums_validation=args.force_checksums_validation,
          **kwargs,
      )
  
      # Add Apache Beam options to download config
      try:
          import apache_beam as beam  # pylint: disable=g-import-not-at-top
      except ImportError:
          beam = None
  
      if beam is not None:
          if args.beam_pipeline_options:
              dl_config.beam_options = (
                  beam.options.pipeline_options.PipelineOptions(
                      flags=[
                          f"--{opt}"
                          for opt in args.beam_pipeline_options.split(
                              ","
                          )
                      ]
                  )
              )
  
      return dl_config
  
imports: import argparse
  import functools
  import importlib
  import itertools
  import json
  import multiprocessing
  import os
  import typing
  from typing import Dict, Iterator, Optional, Tuple, Type, Union
  from absl import logging
  from etils import epath
  import tensorflow_datasets
label_desc: Use image node_id 12 for calling a global function with example usage: _make_download_config(args, dataset_name) and returns: dl_config