<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _run_dir(self, run):
 """Helper that maps a frontend run name to a profile "run" directory. The frontend run name consists of the TensorBoard run name (aka the relative path from the logdir root to the directory containing the data) path-joined to the Profile plugin's "run" concept (which is a subdirectory of the plugins/profile directory representing an individual run of the tool), with the special case that TensorBoard run is the logdir root (which is the run named '.') then only the Profile plugin "run" name is used, for backwards compatibility. To convert back to the actual run directory, we apply the following transformation: - If the run name doesn't contain '/', prepend './' - Split on the rightmost instance of '/' - Assume the left side is a TensorBoard run name and map it to a directory path using EventMultiplexer.RunPaths(), then map that to the profile plugin directory via PluginDirectory() - Assume the right side is a Profile plugin "run" and path-join it to the preceding path to get the final directory Args: run: the frontend run name, as described above, e.g. train/run1. Returns: The resolved directory path, e.g. /logdir/train/plugins/profile/run1. """

    run = run.rstrip('/')
    if '/' not in run:
      run = './' + run
    tb_run_name, _, profile_run_name = run.rpartition('/')
    tb_run_directory = self.multiplexer.RunPaths().get(tb_run_name)
    if tb_run_directory is None:
      # Check if logdir is a directory to handle case where it's actually a
      # multipart directory spec, which this plugin does not support.
      if tb_run_name == '.' and tf.io.gfile.isdir(self.logdir):
        tb_run_directory = self.logdir
      else:
        raise RuntimeError("No matching run directory for run %s" % run)
    plugin_directory = plugin_asset_util.PluginDirectory(
        tb_run_directory, PLUGIN_NAME)
    return os.path.join(plugin_directory, profile_run_name)