We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Enhance the log of SegmentationSaver
**Is your feature request related to a problem? Please describe.**
We need to print out more info when saving segmentation results, now it's only:
```
saved all the model outputs into files.
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `monai/data/nifti_saver.py`
Content:
```
1 # Copyright 2020 - 2021 MONAI Consortium
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
5 #     http://www.apache.org/licenses/LICENSE-2.0
6 # Unless required by applicable law or agreed to in writing, software
7 # distributed under the License is distributed on an "AS IS" BASIS,
8 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 # See the License for the specific language governing permissions and
10 # limitations under the License.
11 
12 from typing import Dict, Optional, Union
13 
14 import numpy as np
15 import torch
16 
17 from monai.config import DtypeLike
18 from monai.data.nifti_writer import write_nifti
19 from monai.data.utils import create_file_basename
20 from monai.utils import GridSampleMode, GridSamplePadMode
21 from monai.utils import ImageMetaKey as Key
22 
23 
24 class NiftiSaver:
25     """
26     Save the data as NIfTI file, it can support single data content or a batch of data.
27     Typically, the data can be segmentation predictions, call `save` for single data
28     or call `save_batch` to save a batch of data together. If no meta data provided,
29     use index from 0 as the filename prefix.
30 
31     NB: image should include channel dimension: [B],C,H,W,[D].
32     """
33 
34     def __init__(
35         self,
36         output_dir: str = "./",
37         output_postfix: str = "seg",
38         output_ext: str = ".nii.gz",
39         resample: bool = True,
40         mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,
41         padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,
42         align_corners: bool = False,
43         dtype: DtypeLike = np.float64,
44         output_dtype: DtypeLike = np.float32,
45         squeeze_end_dims: bool = True,
46         data_root_dir: str = "",
47     ) -> None:
48         """
49         Args:
50             output_dir: output image directory.
51             output_postfix: a string appended to all output file names.
52             output_ext: output file extension name.
53             resample: whether to resample before saving the data array.
54             mode: {``"bilinear"``, ``"nearest"``}
55                 This option is used when ``resample = True``.
56                 Interpolation mode to calculate output values. Defaults to ``"bilinear"``.
57                 See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample
58             padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``}
59                 This option is used when ``resample = True``.
60                 Padding mode for outside grid values. Defaults to ``"border"``.
61                 See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample
62             align_corners: Geometrically, we consider the pixels of the input as squares rather than points.
63                 See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample
64             dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision.
65                 If None, use the data type of input data.
66             output_dtype: data type for saving data. Defaults to ``np.float32``.
67             squeeze_end_dims: if True, any trailing singleton dimensions will be removed (after the channel
68                 has been moved to the end). So if input is (C,H,W,D), this will be altered to (H,W,D,C), and
69                 then if C==1, it will be saved as (H,W,D). If D also ==1, it will be saved as (H,W). If false,
70                 image will always be saved as (H,W,D,C).
71             data_root_dir: if not empty, it specifies the beginning parts of the input file's
72                 absolute path. it's used to compute `input_file_rel_path`, the relative path to the file from
73                 `data_root_dir` to preserve folder structure when saving in case there are files in different
74                 folders with the same file names. for example:
75                 input_file_name: /foo/bar/test1/image.nii,
76                 postfix: seg
77                 output_ext: nii.gz
78                 output_dir: /output,
79                 data_root_dir: /foo/bar,
80                 output will be: /output/test1/image/image_seg.nii.gz
81 
82         """
83         self.output_dir = output_dir
84         self.output_postfix = output_postfix
85         self.output_ext = output_ext
86         self.resample = resample
87         self.mode: GridSampleMode = GridSampleMode(mode)
88         self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)
89         self.align_corners = align_corners
90         self.dtype = dtype
91         self.output_dtype = output_dtype
92         self._data_index = 0
93         self.squeeze_end_dims = squeeze_end_dims
94         self.data_root_dir = data_root_dir
95 
96     def save(self, data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:
97         """
98         Save data into a Nifti file.
99         The meta_data could optionally have the following keys:
100 
101             - ``'filename_or_obj'`` -- for output file name creation, corresponding to filename or object.
102             - ``'original_affine'`` -- for data orientation handling, defaulting to an identity matrix.
103             - ``'affine'`` -- for data output affine, defaulting to an identity matrix.
104             - ``'spatial_shape'`` -- for data output shape.
105             - ``'patch_index'`` -- if the data is a patch of big image, append the patch index to filename.
106 
107         When meta_data is specified, the saver will try to resample batch data from the space
108         defined by "affine" to the space defined by "original_affine".
109 
110         If meta_data is None, use the default index (starting from 0) as the filename.
111 
112         Args:
113             data: target data content that to be saved as a NIfTI format file.
114                 Assuming the data shape starts with a channel dimension and followed by spatial dimensions.
115             meta_data: the meta data information corresponding to the data.
116 
117         See Also
118             :py:meth:`monai.data.nifti_writer.write_nifti`
119         """
120         filename = meta_data[Key.FILENAME_OR_OBJ] if meta_data else str(self._data_index)
121         self._data_index += 1
122         original_affine = meta_data.get("original_affine", None) if meta_data else None
123         affine = meta_data.get("affine", None) if meta_data else None
124         spatial_shape = meta_data.get("spatial_shape", None) if meta_data else None
125         patch_index = meta_data.get(Key.PATCH_INDEX, None) if meta_data else None
126 
127         if isinstance(data, torch.Tensor):
128             data = data.detach().cpu().numpy()
129 
130         path = create_file_basename(self.output_postfix, filename, self.output_dir, self.data_root_dir, patch_index)
131         path = f"{path}{self.output_ext}"
132         # change data shape to be (channel, h, w, d)
133         while len(data.shape) < 4:
134             data = np.expand_dims(data, -1)
135         # change data to "channel last" format and write to nifti format file
136         data = np.moveaxis(np.asarray(data), 0, -1)
137 
138         # if desired, remove trailing singleton dimensions
139         if self.squeeze_end_dims:
140             while data.shape[-1] == 1:
141                 data = np.squeeze(data, -1)
142 
143         write_nifti(
144             data,
145             file_name=path,
146             affine=affine,
147             target_affine=original_affine,
148             resample=self.resample,
149             output_spatial_shape=spatial_shape,
150             mode=self.mode,
151             padding_mode=self.padding_mode,
152             align_corners=self.align_corners,
153             dtype=self.dtype,
154             output_dtype=self.output_dtype,
155         )
156 
157     def save_batch(self, batch_data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:
158         """
159         Save a batch of data into Nifti format files.
160 
161         Spatially it supports up to three dimensions, that is, H, HW, HWD for
162         1D, 2D, 3D respectively (with resampling supports for 2D and 3D only).
163 
164         When saving multiple time steps or multiple channels `batch_data`,
165         time and/or modality axes should be appended after the batch dimensions.
166         For example, the shape of a batch of 2D eight-class
167         segmentation probabilities to be saved could be `(batch, 8, 64, 64)`;
168         in this case each item in the batch will be saved as (64, 64, 1, 8)
169         NIfTI file (the third dimension is reserved as a spatial dimension).
170 
171         Args:
172             batch_data: target batch data content that save into NIfTI format.
173             meta_data: every key-value in the meta_data is corresponding to a batch of data.
174 
175         """
176         for i, data in enumerate(batch_data):  # save a batch of files
177             self.save(data=data, meta_data={k: meta_data[k][i] for k in meta_data} if meta_data is not None else None)
178
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/monai/data/nifti_saver.py b/monai/data/nifti_saver.py
--- a/monai/data/nifti_saver.py
+++ b/monai/data/nifti_saver.py
@@ -153,6 +153,7 @@
             dtype=self.dtype,
             output_dtype=self.output_dtype,
         )
+        print(f"file written: {path}.")
 
     def save_batch(self, batch_data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:
         """

{"golden_diff": "diff --git a/monai/data/nifti_saver.py b/monai/data/nifti_saver.py\n--- a/monai/data/nifti_saver.py\n+++ b/monai/data/nifti_saver.py\n@@ -153,6 +153,7 @@\n             dtype=self.dtype,\n             output_dtype=self.output_dtype,\n         )\n+        print(f\"file written: {path}.\")\n \n     def save_batch(self, batch_data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:\n         \"\"\"\n", "issue": "Enhance the log of SegmentationSaver\n**Is your feature request related to a problem? Please describe.**\r\nWe need to print out more info when saving segmentation results, now it's only:\r\n```\r\nsaved all the model outputs into files.\r\n```\r\n\n", "before_files": [{"content": "# Copyright 2020 - 2021 MONAI Consortium\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#     http://www.apache.org/licenses/LICENSE-2.0\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom typing import Dict, Optional, Union\n\nimport numpy as np\nimport torch\n\nfrom monai.config import DtypeLike\nfrom monai.data.nifti_writer import write_nifti\nfrom monai.data.utils import create_file_basename\nfrom monai.utils import GridSampleMode, GridSamplePadMode\nfrom monai.utils import ImageMetaKey as Key\n\n\nclass NiftiSaver:\n    \"\"\"\n    Save the data as NIfTI file, it can support single data content or a batch of data.\n    Typically, the data can be segmentation predictions, call `save` for single data\n    or call `save_batch` to save a batch of data together. If no meta data provided,\n    use index from 0 as the filename prefix.\n\n    NB: image should include channel dimension: [B],C,H,W,[D].\n    \"\"\"\n\n    def __init__(\n        self,\n        output_dir: str = \"./\",\n        output_postfix: str = \"seg\",\n        output_ext: str = \".nii.gz\",\n        resample: bool = True,\n        mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n        padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,\n        align_corners: bool = False,\n        dtype: DtypeLike = np.float64,\n        output_dtype: DtypeLike = np.float32,\n        squeeze_end_dims: bool = True,\n        data_root_dir: str = \"\",\n    ) -> None:\n        \"\"\"\n        Args:\n            output_dir: output image directory.\n            output_postfix: a string appended to all output file names.\n            output_ext: output file extension name.\n            resample: whether to resample before saving the data array.\n            mode: {``\"bilinear\"``, ``\"nearest\"``}\n                This option is used when ``resample = True``.\n                Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n                See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n            padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n                This option is used when ``resample = True``.\n                Padding mode for outside grid values. Defaults to ``\"border\"``.\n                See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n            align_corners: Geometrically, we consider the pixels of the input as squares rather than points.\n                See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n            dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision.\n                If None, use the data type of input data.\n            output_dtype: data type for saving data. Defaults to ``np.float32``.\n            squeeze_end_dims: if True, any trailing singleton dimensions will be removed (after the channel\n                has been moved to the end). So if input is (C,H,W,D), this will be altered to (H,W,D,C), and\n                then if C==1, it will be saved as (H,W,D). If D also ==1, it will be saved as (H,W). If false,\n                image will always be saved as (H,W,D,C).\n            data_root_dir: if not empty, it specifies the beginning parts of the input file's\n                absolute path. it's used to compute `input_file_rel_path`, the relative path to the file from\n                `data_root_dir` to preserve folder structure when saving in case there are files in different\n                folders with the same file names. for example:\n                input_file_name: /foo/bar/test1/image.nii,\n                postfix: seg\n                output_ext: nii.gz\n                output_dir: /output,\n                data_root_dir: /foo/bar,\n                output will be: /output/test1/image/image_seg.nii.gz\n\n        \"\"\"\n        self.output_dir = output_dir\n        self.output_postfix = output_postfix\n        self.output_ext = output_ext\n        self.resample = resample\n        self.mode: GridSampleMode = GridSampleMode(mode)\n        self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)\n        self.align_corners = align_corners\n        self.dtype = dtype\n        self.output_dtype = output_dtype\n        self._data_index = 0\n        self.squeeze_end_dims = squeeze_end_dims\n        self.data_root_dir = data_root_dir\n\n    def save(self, data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:\n        \"\"\"\n        Save data into a Nifti file.\n        The meta_data could optionally have the following keys:\n\n            - ``'filename_or_obj'`` -- for output file name creation, corresponding to filename or object.\n            - ``'original_affine'`` -- for data orientation handling, defaulting to an identity matrix.\n            - ``'affine'`` -- for data output affine, defaulting to an identity matrix.\n            - ``'spatial_shape'`` -- for data output shape.\n            - ``'patch_index'`` -- if the data is a patch of big image, append the patch index to filename.\n\n        When meta_data is specified, the saver will try to resample batch data from the space\n        defined by \"affine\" to the space defined by \"original_affine\".\n\n        If meta_data is None, use the default index (starting from 0) as the filename.\n\n        Args:\n            data: target data content that to be saved as a NIfTI format file.\n                Assuming the data shape starts with a channel dimension and followed by spatial dimensions.\n            meta_data: the meta data information corresponding to the data.\n\n        See Also\n            :py:meth:`monai.data.nifti_writer.write_nifti`\n        \"\"\"\n        filename = meta_data[Key.FILENAME_OR_OBJ] if meta_data else str(self._data_index)\n        self._data_index += 1\n        original_affine = meta_data.get(\"original_affine\", None) if meta_data else None\n        affine = meta_data.get(\"affine\", None) if meta_data else None\n        spatial_shape = meta_data.get(\"spatial_shape\", None) if meta_data else None\n        patch_index = meta_data.get(Key.PATCH_INDEX, None) if meta_data else None\n\n        if isinstance(data, torch.Tensor):\n            data = data.detach().cpu().numpy()\n\n        path = create_file_basename(self.output_postfix, filename, self.output_dir, self.data_root_dir, patch_index)\n        path = f\"{path}{self.output_ext}\"\n        # change data shape to be (channel, h, w, d)\n        while len(data.shape) < 4:\n            data = np.expand_dims(data, -1)\n        # change data to \"channel last\" format and write to nifti format file\n        data = np.moveaxis(np.asarray(data), 0, -1)\n\n        # if desired, remove trailing singleton dimensions\n        if self.squeeze_end_dims:\n            while data.shape[-1] == 1:\n                data = np.squeeze(data, -1)\n\n        write_nifti(\n            data,\n            file_name=path,\n            affine=affine,\n            target_affine=original_affine,\n            resample=self.resample,\n            output_spatial_shape=spatial_shape,\n            mode=self.mode,\n            padding_mode=self.padding_mode,\n            align_corners=self.align_corners,\n            dtype=self.dtype,\n            output_dtype=self.output_dtype,\n        )\n\n    def save_batch(self, batch_data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:\n        \"\"\"\n        Save a batch of data into Nifti format files.\n\n        Spatially it supports up to three dimensions, that is, H, HW, HWD for\n        1D, 2D, 3D respectively (with resampling supports for 2D and 3D only).\n\n        When saving multiple time steps or multiple channels `batch_data`,\n        time and/or modality axes should be appended after the batch dimensions.\n        For example, the shape of a batch of 2D eight-class\n        segmentation probabilities to be saved could be `(batch, 8, 64, 64)`;\n        in this case each item in the batch will be saved as (64, 64, 1, 8)\n        NIfTI file (the third dimension is reserved as a spatial dimension).\n\n        Args:\n            batch_data: target batch data content that save into NIfTI format.\n            meta_data: every key-value in the meta_data is corresponding to a batch of data.\n\n        \"\"\"\n        for i, data in enumerate(batch_data):  # save a batch of files\n            self.save(data=data, meta_data={k: meta_data[k][i] for k in meta_data} if meta_data is not None else None)\n", "path": "monai/data/nifti_saver.py"}], "after_files": [{"content": "# Copyright 2020 - 2021 MONAI Consortium\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#     http://www.apache.org/licenses/LICENSE-2.0\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom typing import Dict, Optional, Union\n\nimport numpy as np\nimport torch\n\nfrom monai.config import DtypeLike\nfrom monai.data.nifti_writer import write_nifti\nfrom monai.data.utils import create_file_basename\nfrom monai.utils import GridSampleMode, GridSamplePadMode\nfrom monai.utils import ImageMetaKey as Key\n\n\nclass NiftiSaver:\n    \"\"\"\n    Save the data as NIfTI file, it can support single data content or a batch of data.\n    Typically, the data can be segmentation predictions, call `save` for single data\n    or call `save_batch` to save a batch of data together. If no meta data provided,\n    use index from 0 as the filename prefix.\n\n    NB: image should include channel dimension: [B],C,H,W,[D].\n    \"\"\"\n\n    def __init__(\n        self,\n        output_dir: str = \"./\",\n        output_postfix: str = \"seg\",\n        output_ext: str = \".nii.gz\",\n        resample: bool = True,\n        mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n        padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,\n        align_corners: bool = False,\n        dtype: DtypeLike = np.float64,\n        output_dtype: DtypeLike = np.float32,\n        squeeze_end_dims: bool = True,\n        data_root_dir: str = \"\",\n    ) -> None:\n        \"\"\"\n        Args:\n            output_dir: output image directory.\n            output_postfix: a string appended to all output file names.\n            output_ext: output file extension name.\n            resample: whether to resample before saving the data array.\n            mode: {``\"bilinear\"``, ``\"nearest\"``}\n                This option is used when ``resample = True``.\n                Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n                See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n            padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n                This option is used when ``resample = True``.\n                Padding mode for outside grid values. Defaults to ``\"border\"``.\n                See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n            align_corners: Geometrically, we consider the pixels of the input as squares rather than points.\n                See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n            dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision.\n                If None, use the data type of input data.\n            output_dtype: data type for saving data. Defaults to ``np.float32``.\n            squeeze_end_dims: if True, any trailing singleton dimensions will be removed (after the channel\n                has been moved to the end). So if input is (C,H,W,D), this will be altered to (H,W,D,C), and\n                then if C==1, it will be saved as (H,W,D). If D also ==1, it will be saved as (H,W). If false,\n                image will always be saved as (H,W,D,C).\n            data_root_dir: if not empty, it specifies the beginning parts of the input file's\n                absolute path. it's used to compute `input_file_rel_path`, the relative path to the file from\n                `data_root_dir` to preserve folder structure when saving in case there are files in different\n                folders with the same file names. for example:\n                input_file_name: /foo/bar/test1/image.nii,\n                postfix: seg\n                output_ext: nii.gz\n                output_dir: /output,\n                data_root_dir: /foo/bar,\n                output will be: /output/test1/image/image_seg.nii.gz\n\n        \"\"\"\n        self.output_dir = output_dir\n        self.output_postfix = output_postfix\n        self.output_ext = output_ext\n        self.resample = resample\n        self.mode: GridSampleMode = GridSampleMode(mode)\n        self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)\n        self.align_corners = align_corners\n        self.dtype = dtype\n        self.output_dtype = output_dtype\n        self._data_index = 0\n        self.squeeze_end_dims = squeeze_end_dims\n        self.data_root_dir = data_root_dir\n\n    def save(self, data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:\n        \"\"\"\n        Save data into a Nifti file.\n        The meta_data could optionally have the following keys:\n\n            - ``'filename_or_obj'`` -- for output file name creation, corresponding to filename or object.\n            - ``'original_affine'`` -- for data orientation handling, defaulting to an identity matrix.\n            - ``'affine'`` -- for data output affine, defaulting to an identity matrix.\n            - ``'spatial_shape'`` -- for data output shape.\n            - ``'patch_index'`` -- if the data is a patch of big image, append the patch index to filename.\n\n        When meta_data is specified, the saver will try to resample batch data from the space\n        defined by \"affine\" to the space defined by \"original_affine\".\n\n        If meta_data is None, use the default index (starting from 0) as the filename.\n\n        Args:\n            data: target data content that to be saved as a NIfTI format file.\n                Assuming the data shape starts with a channel dimension and followed by spatial dimensions.\n            meta_data: the meta data information corresponding to the data.\n\n        See Also\n            :py:meth:`monai.data.nifti_writer.write_nifti`\n        \"\"\"\n        filename = meta_data[Key.FILENAME_OR_OBJ] if meta_data else str(self._data_index)\n        self._data_index += 1\n        original_affine = meta_data.get(\"original_affine\", None) if meta_data else None\n        affine = meta_data.get(\"affine\", None) if meta_data else None\n        spatial_shape = meta_data.get(\"spatial_shape\", None) if meta_data else None\n        patch_index = meta_data.get(Key.PATCH_INDEX, None) if meta_data else None\n\n        if isinstance(data, torch.Tensor):\n            data = data.detach().cpu().numpy()\n\n        path = create_file_basename(self.output_postfix, filename, self.output_dir, self.data_root_dir, patch_index)\n        path = f\"{path}{self.output_ext}\"\n        # change data shape to be (channel, h, w, d)\n        while len(data.shape) < 4:\n            data = np.expand_dims(data, -1)\n        # change data to \"channel last\" format and write to nifti format file\n        data = np.moveaxis(np.asarray(data), 0, -1)\n\n        # if desired, remove trailing singleton dimensions\n        if self.squeeze_end_dims:\n            while data.shape[-1] == 1:\n                data = np.squeeze(data, -1)\n\n        write_nifti(\n            data,\n            file_name=path,\n            affine=affine,\n            target_affine=original_affine,\n            resample=self.resample,\n            output_spatial_shape=spatial_shape,\n            mode=self.mode,\n            padding_mode=self.padding_mode,\n            align_corners=self.align_corners,\n            dtype=self.dtype,\n            output_dtype=self.output_dtype,\n        )\n        print(f\"file written: {path}.\")\n\n    def save_batch(self, batch_data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:\n        \"\"\"\n        Save a batch of data into Nifti format files.\n\n        Spatially it supports up to three dimensions, that is, H, HW, HWD for\n        1D, 2D, 3D respectively (with resampling supports for 2D and 3D only).\n\n        When saving multiple time steps or multiple channels `batch_data`,\n        time and/or modality axes should be appended after the batch dimensions.\n        For example, the shape of a batch of 2D eight-class\n        segmentation probabilities to be saved could be `(batch, 8, 64, 64)`;\n        in this case each item in the batch will be saved as (64, 64, 1, 8)\n        NIfTI file (the third dimension is reserved as a spatial dimension).\n\n        Args:\n            batch_data: target batch data content that save into NIfTI format.\n            meta_data: every key-value in the meta_data is corresponding to a batch of data.\n\n        \"\"\"\n        for i, data in enumerate(batch_data):  # save a batch of files\n            self.save(data=data, meta_data={k: meta_data[k][i] for k in meta_data} if meta_data is not None else None)\n", "path": "monai/data/nifti_saver.py"}]}