code: def mock_env_with_temp(path):
      d = tempfile.TemporaryDirectory()
      patched = patch(path, return_value=d.name)
      patched.start()
      yield d.name
      d.cleanup()
      patched.stop()
  
imports: import contextlib
  import os
  import tempfile
  import unittest
  from unittest.mock import patch
  import torch
  from mmf.trainers.callbacks.checkpoint import CheckpointCallback
  from mmf.trainers.callbacks.early_stopping import EarlyStoppingCallback
  from mmf.trainers.lightning_core.loop_callback import LightningLoopCallback
  from mmf.utils.checkpoint import get_ckpt_path_from_folder
  from mmf.utils.download import download_pretrained_model
  from tests.test_utils import skip_if_no_network
  from tests.trainers.test_utils import get_config_with_defaults, get_lightning_trainer, get_mmf_trainer, prepare_lightning_trainer
label_desc: Use image node_id 1 for calling a global function with example usage: mock_env_with_temp(path) without return types