class_docstr: Write data and metadata into files on disk using Nibabel.
  
  .. code-block:: python
  
      import numpy as np
      from monai.data import NibabelWriter
  
      np_data = np.arange(48).reshape(3, 4, 4)
      writer = NibabelWriter()
      writer.set_data_array(np_data, channel_dim=None)
      writer.set_metadata({"affine": np.eye(4), "original_affine": np.eye(4)})
      writer.write("test1.nii.gz", verbose=True)
class_docstr_tok: ["Write","data","and","metadata","into","files","on","disk","using","Nibabel",".","..","code-block",":",":","python","import","numpy","as","np","from","monai.data","import","NibabelWriter","np_data","=","np.arange","(","48",")",".reshape","(","3",",","4",",","4",")","writer","=","NibabelWriter","(",")","writer.set_data_array","(","np_data",",","channel_dim=None",")","writer.set_metadata","(","{","``","affine","''",":","np.eye","(","4",")",",","``","original_affine","''",":","np.eye","(","4",")","}",")","writer.write","(","``","test1.nii.gz","''",",","verbose=True",")"]
docstr: Create an Nifti1Image object from ``data_array``. This method assumes a 'channel-last' ``data_array``.
  
  Args:
      data_array: input data array.
      affine: affine matrix of the data array.
      dtype: output data type.
      kwargs: keyword arguments. Current ``nib.nifti1.Nifti1Image`` will read
          ``header``, ``extra``, ``file_map`` from this dictionary.
  
  See also:
  
      - https://nipy.org/nibabel/reference/nibabel.nifti1.html#nibabel.nifti1.Nifti1Image
docstr_tok: ["Create","an","Nifti1Image","object","from","``","data_array","``",".","This","method","assumes","a","'channel-last","'","``","data_array","``",".","Args",":","data_array",":","input","data","array",".","affine",":","affine","matrix","of","the","data","array",".","dtype",":","output","data","type",".","kwargs",":","keyword","arguments",".","Current","``","nib.nifti1.Nifti1Image","``","will","read","``","header","``",",","``","extra","``",",","``","file_map","``","from","this","dictionary",".","See","also",":","-","https",":","\/\/nipy.org\/nibabel\/reference\/nibabel.nifti1.html","#","nibabel.nifti1.Nifti1Image"]
code: def create_backend_obj(
      cls,
      data_array: NdarrayOrTensor,
      affine: NdarrayOrTensor | None = None,
      dtype: DtypeLike = None,
      **kwargs,
  ):
      """
      Create an Nifti1Image object from ``data_array``. This method assumes a 'channel-last' ``data_array``.
  
      Args:
          data_array: input data array.
          affine: affine matrix of the data array.
          dtype: output data type.
          kwargs: keyword arguments. Current ``nib.nifti1.Nifti1Image`` will read
              ``header``, ``extra``, ``file_map`` from this dictionary.
  
      See also:
  
          - https://nipy.org/nibabel/reference/nibabel.nifti1.html#nibabel.nifti1.Nifti1Image
      """
      data_array = super().create_backend_obj(data_array)
      if dtype is not None:
          data_array = data_array.astype(
              get_equivalent_dtype(dtype, np.ndarray), copy=False
          )
      affine = convert_data_type(affine, np.ndarray)[0]
      if affine is None:
          affine = np.eye(4)
      affine = to_affine_nd(r=3, affine=affine)
      return nib.nifti1.Nifti1Image(
          data_array,
          affine,
          header=kwargs.pop("header", None),
          extra=kwargs.pop("extra", None),
          file_map=kwargs.pop("file_map", None),
      )
  
imports: from __future__ import annotations
  from collections.abc import Mapping, Sequence
  from typing import TYPE_CHECKING, Any, cast
  import numpy
  from monai.apps.utils import get_logger
  from monai.config import DtypeLike, NdarrayOrTensor, PathLike
  from monai.data.meta_tensor import MetaTensor
  from monai.data.utils import affine_to_spacing, ensure_tuple, ensure_tuple_rep, orientation_ras_lps, to_affine_nd
  from monai.transforms.spatial.array import Resize, SpatialResample
  from monai.transforms.utils_pytorch_numpy_unification import ascontiguousarray, moveaxis
  from monai.utils import GridSampleMode, GridSamplePadMode, InterpolateMode, MetaKeys, OptionalImportError, SpaceKeys, convert_data_type, convert_to_tensor, get_equivalent_dtype, look_up_option, optional_import, require_pkg
label_desc: Use image node_id 5 for calling the NibabelWriter obj's underlying member method code with example usage: obj.create_backend_obj(cls, data_array, affine, dtype) and returns: nib