class_docstr: Handle the lifecycle and configuration of a local container execution.
  
  This class is responsible for creating the directories and configuration
  files that the docker containers will use for either training or serving.
class_docstr_tok: ["Handle","the","lifecycle","and","configuration","of","a","local","container","execution",".","This","class","is","responsible","for","creating","the","directories","and","configuration","files","that","the","docker","containers","will","use","for","either","training","or","serving","."]
docstr: Prepares the training volumes based on input and output data configs.
  
  Args:
      data_dir:
      input_data_config:
      output_data_config:
      hyperparameters:
docstr_tok: ["Prepares","the","training","volumes","based","on","input","and","output","data","configs",".","Args",":","data_dir",":","input_data_config",":","output_data_config",":","hyperparameters",":"]
code: def _prepare_training_volumes(
      self,
      data_dir,
      input_data_config,
      output_data_config,
      hyperparameters,
  ):
      """Prepares the training volumes based on input and output data configs.
  
      Args:
          data_dir:
          input_data_config:
          output_data_config:
          hyperparameters:
      """
      shared_dir = os.path.join(self.container_root, "shared")
      model_dir = os.path.join(self.container_root, "model")
      volumes = []
  
      volumes.append(_Volume(model_dir, "/opt/ml/model"))
  
      # Mount the metadata directory if present.
      # Only expected to be present on SM notebook instances.
      # This is used by some DeepEngine libraries
      metadata_dir = "/opt/ml/metadata"
      if os.path.isdir(metadata_dir):
          volumes.append(_Volume(metadata_dir, metadata_dir))
  
      # Set up the channels for the containers. For local data we will
      # mount the local directory to the container. For S3 Data we will download the S3 data
      # first.
      for channel in input_data_config:
          uri = channel["DataUri"]
          channel_name = channel["ChannelName"]
          channel_dir = os.path.join(data_dir, channel_name)
          os.mkdir(channel_dir)
  
          data_source = sagemaker.local.data.get_data_source_instance(
              uri, self.sagemaker_session
          )
          volumes.append(
              _Volume(data_source.get_root_dir(), channel=channel_name)
          )
  
      # If there is a training script directory and it is a local directory,
      # mount it to the container.
      if sagemaker.estimator.DIR_PARAM_NAME in hyperparameters:
          training_dir = json.loads(
              hyperparameters[sagemaker.estimator.DIR_PARAM_NAME]
          )
          parsed_uri = urlparse(training_dir)
          if parsed_uri.scheme == "file":
              host_dir = os.path.abspath(
                  parsed_uri.netloc + parsed_uri.path
              )
              volumes.append(_Volume(host_dir, "/opt/ml/code"))
              # Also mount a directory that all the containers can access.
              volumes.append(_Volume(shared_dir, "/opt/ml/shared"))
  
      parsed_uri = urlparse(output_data_config["S3OutputPath"])
      if (
          parsed_uri.scheme == "file"
          and sagemaker.model.SAGEMAKER_OUTPUT_LOCATION
          in hyperparameters
      ):
          dir_path = os.path.abspath(
              parsed_uri.netloc + parsed_uri.path
          )
          intermediate_dir = os.path.join(
              dir_path, "output", "intermediate"
          )
          if not os.path.exists(intermediate_dir):
              os.makedirs(intermediate_dir)
          volumes.append(
              _Volume(intermediate_dir, "/opt/ml/output/intermediate")
          )
  
      return volumes
  
imports: from __future__ import absolute_import, annotations
  import base64
  import copy
  import errno
  import json
  import logging
  import os
  import platform
  import random
  import re
  import shlex
  import shutil
  import string
  import subprocess
  import sys
  import tarfile
  import tempfile
  from distutils.spawn import find_executable
  from threading import Thread
  from typing import Dict, List
  from six.moves.urllib.parse import urlparse
  import sagemaker
  from sagemaker.config.config_schema import CONTAINER_CONFIG, LOCAL
  import sagemaker.local.data
  import sagemaker.local.utils
  import sagemaker.utils
label_desc: Use image node_id 10 for calling the _SageMakerContainer obj's underlying member method code with example usage: obj._prepare_training_volumes(data_dir, input_data_config, output_data_config, hyperparameters) and returns: volumes