docstr: Infer cached steps.
  :param rule_name: The name of the Make rule to run.
  :param steps_to_run: The step names obtained by parsing the Make output showing
                       which steps will be executed.
  :param recipe_step_names:  A list of all the step names contained in the specified
                               recipe sorted by the execution order.
docstr_tok: ["Infer","cached","steps",".",":","param","rule_name",":","The","name","of","the","Make","rule","to","run",".",":","param","steps_to_run",":","The","step","names","obtained","by","parsing","the","Make","output","showing","which","steps","will","be","executed",".",":","param","recipe_step_names",":","A","list","of","all","the","step","names","contained","in","the","specified","recipe","sorted","by","the","execution","order","."]
code: def _infer_cached_steps(
      rule_name, steps_to_run, recipe_step_names
  ) -> List[str]:
      """
      Infer cached steps.
      :param rule_name: The name of the Make rule to run.
      :param steps_to_run: The step names obtained by parsing the Make output showing
                           which steps will be executed.
      :param recipe_step_names:  A list of all the step names contained in the specified
                                   recipe sorted by the execution order.
      """
      index = recipe_step_names.index(rule_name)
      if index == 0:
          # If the rule_name is ingest, it should always be executed
          return []
  
      if len(steps_to_run) == 0:
          # All steps are cached
          return recipe_step_names[: index + 1]
  
      first_step_index = min(
          [recipe_step_names.index(step) for step in steps_to_run]
      )
      return recipe_step_names[:first_step_index]
  
imports: import hashlib
  import logging
  import os
  import pathlib
  import re
  import shutil
  from typing import Dict, List
  from mlflow.environment_variables import MLFLOW_RECIPES_EXECUTION_DIRECTORY, MLFLOW_RECIPES_EXECUTION_TARGET_STEP_NAME
  from mlflow.recipes.step import BaseStep, StepStatus
  from mlflow.utils.file_utils import read_yaml, write_yaml
  from mlflow.utils.process import _exec_cmd
label_desc: Use image node_id 3 for calling the _ExecutionPlan obj's underlying member method code with example usage: obj._infer_cached_steps(rule_name, steps_to_run, recipe_step_names) and returns: recipe_step_names, list, recipe_step_names