code: def _get_sanitized_model_directory(model_directory: Text) -> Text:
      """Adjusts the `--model` argument of `rasa test core` when called with
      `--evaluate-model-directory`.
  
      By default rasa uses the latest model for the `--model` parameter. However, for
      `--evaluate-model-directory` we need a directory. This function checks if the
      passed parameter is a model or an individual model file.
  
      Args:
          model_directory: The model_directory argument that was given to
          `test_core_models_in_directory`.
  
      Returns: The adjusted model_directory that should be used in
          `test_core_models_in_directory`.
      """
      p = Path(model_directory)
      if p.is_file():
          if model_directory != rasa.model.get_latest_model():
              rasa.shared.utils.cli.print_warning(
                  "You passed a file as '--model'. Will use the directory containing "
                  "this file instead."
              )
          model_directory = str(p.parent)
  
      return model_directory
  
imports: import copy
  import logging
  import os
  from typing import Text, Dict, Optional, List, Any, Iterable, Tuple, Union
  from pathlib import Path
  from rasa.core.agent import Agent
  from rasa.engine.storage.local_model_storage import LocalModelStorage
  import rasa.shared.utils.cli
  import rasa.shared.utils.common
  import rasa.shared.utils.io
  import rasa.utils.common
  from rasa.constants import RESULTS_FILE, NUMBER_OF_TRAINING_STORIES_FILE
  from rasa.exceptions import ModelNotFound
  from rasa.shared.constants import DEFAULT_RESULTS_PATH
  import rasa.shared.nlu.training_data.loading
  from rasa.shared.data import TrainingType
  from rasa.shared.nlu.training_data.training_data import TrainingData
  import rasa.model
label_desc: Use image node_id 2 for calling a global function with example usage: _get_sanitized_model_directory(model_directory) and returns: model_directory