code: def _test_no_chdir(
      runner_type, runtime_env, use_deprecated_config=False
  ):
      # Write a data file that we want to read in our training loop
      with open("./read.txt", "w") as f:
          f.write("data")
  
      ray.init(num_cpus=4, runtime_env=runtime_env)
  
      def train_func(config):
          # Make sure we can access the data from the original working dir
          assert (
              os.path.exists("./read.txt")
              and open("./read.txt", "r").read() == "data"
          )
  
          # Write operations should happen in each trial's independent logdir to
          # prevent write conflicts
          trial_dir = Path(train.get_context().get_trial_dir())
          trial_dir.joinpath("write.txt").touch()
  
      if runner_type == "trainer":
          trainer = DataParallelTrainer(
              train_func,
              scaling_config=train.ScalingConfig(num_workers=2),
          )
          result = trainer.fit()
          results = [result]
      elif runner_type == "tuner":
          tuner = Tuner(
              train_func,
              param_space={"id": tune.grid_search(list(range(4)))},
              tune_config=(
                  TuneConfig(chdir_to_trial_dir=False)
                  if use_deprecated_config
                  else None
              ),
          )
          results = tuner.fit()
          assert not results.errors
      else:
          raise NotImplementedError(f"Invalid: {runner_type}")
  
      for result in results:
          assert os.path.exists(os.path.join(result.path, "write.txt"))
  
imports: import os
  from pathlib import Path
  from unittest.mock import patch
  import pytest
  import unittest
  from typing import Optional
  from sklearn.datasets import load_breast_cancer
  from sklearn.utils import shuffle
  import ray
  from ray import train, tune
  from ray.train import CheckpointConfig, RunConfig, ScalingConfig
  from ray.train.constants import RAY_CHDIR_TO_TRIAL_DIR
  from ray.train.examples.pytorch.torch_linear_example import train_func
  from ray.data import Dataset, Datasource, ReadTask, from_pandas, read_datasource
  from ray.data.block import BlockMetadata
  from ray.train.data_parallel_trainer import DataParallelTrainer
  from ray.train.torch import TorchTrainer
  from ray.train.trainer import BaseTrainer
  from ray.train.xgboost import XGBoostTrainer
  from ray.tune import Callback, CLIReporter
  from ray.tune.tune_config import TuneConfig
  from ray.tune.tuner import Tuner
label_desc: Use image node_id 11 for calling a global function with example usage: _test_no_chdir(runner_type, runtime_env, use_deprecated_config) without return types