code: def test_custom_folderlayout(self, test_data, output_ext, resample):
      class TestFolderLayout(FolderLayoutBase):
          def __init__(
              self, basepath: Path, extension: str, makedirs: bool
          ):
              self.basepath = basepath
              self.ext = extension
              self.makedirs = makedirs
  
          def filename(self, **kwargs) -> PathLike:
              p = self.basepath / str(kwargs["subdirectory"])
              if not p.exists() and self.makedirs:
                  p.mkdir()
  
              return p / (str(kwargs["filename"]) + self.ext)
  
      def name_formatter(metadict: dict, _) -> dict:
          # "[filename].[ext]"
          # quick and dirty split on .
          base_filename = metadict["filename_or_obj"].split(".")[0]
  
          return {"subdirectory": base_filename, "filename": "image"}
  
      with tempfile.TemporaryDirectory() as tempdir:
          trans = SaveImaged(
              keys=["img", "pred"],
              resample=resample,
              allow_missing_keys=True,
              output_name_formatter=name_formatter,
              folder_layout=TestFolderLayout(
                  basepath=Path(tempdir),
                  extension=output_ext,
                  makedirs=True,
              ),
          )
          trans(test_data)
  
          filepath = os.path.join("testfile0", "image" + output_ext)
          self.assertTrue(
              os.path.exists(os.path.join(tempdir, filepath))
          )
  
file_path: MONAI/tests/test_save_imaged.py
imports: from __future__ import annotations
  import os
  import tempfile
  import unittest
  from pathlib import Path
  import torch
  from parameterized import parameterized
  from monai.config import PathLike
  from monai.data.folder_layout import FolderLayoutBase
  from monai.data.meta_tensor import MetaTensor
  from monai.transforms import SaveImaged
  from monai.utils import optional_import
label_desc: Use image node_id 2 for calling the TestSaveImaged obj's underlying member method code with example usage: obj.test_custom_folderlayout(test_data, output_ext, resample) and returns: dict, unknown