def METHOD_NAME(
    item: Union[xr.Dataset, str], d_in: str, d_out: str, chunks: ChunkSpec,
):
    logger.info(f"Processing {item}")
    try:
        dest = os.path.join(d_out, os.path.relpath(item, d_in))  # type: ignore
    except TypeError:
        # is an xarray
        relpath = os.path.relpath(item.path, d_in)  # type: ignore
        chunks = chunks.get(relpath, CHUNKS_DEFAULT)
        clear_encoding(item)
        chunked = rechunk(item, chunks)
        chunked = encode_chunks(chunked, chunks)
        dest = os.path.join(d_out, relpath)
        chunked = cast_time(chunked)
        chunked = drop_redundant_time_avg_vars(chunked)
        chunked.to_zarr(dest, mode="w", consolidated=True)
    except ValueError:
        # is an empty xarray, do nothing
        logger.warning(f"Skipping {item} since it is an empty dataset.")
        pass
    else:
        os.makedirs(os.path.dirname(dest), exist_ok=True)
        try:
            shutil.copy(item, dest)  # type: ignore
        except FileNotFoundError:
            logger.warning(f"{item} not found. Possibly a broken symlink.")