<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def save_as_nifti_file(data: np.ndarray, affine: np.ndarray, path: Union[str, Path]) -> None: """Create a Nifti file and save it. Parameters data Brain data. affine Affine of the image, usually inherited from an existing image. path Output filename. """

    if not isinstance(path, str):
        path = str(path)
    img = Nifti1Pair(data, affine)
    nib.nifti1.save(img, path)