code: def crop_to_nonzero(data, seg=None, nonzero_label=-1):
      nonzero_mask = create_nonzero_mask(data)
      bbox = get_bbox_from_mask(nonzero_mask, 0)
  
      cropped_data = []
      for c in range(data.shape[0]):
          cropped = crop_to_bbox(data[c], bbox)
          cropped_data.append(cropped[None])
      data = np.vstack(cropped_data)
  
      if seg is not None:
          cropped_seg = []
          for c in range(seg.shape[0]):
              cropped = crop_to_bbox(seg[c], bbox)
              cropped_seg.append(cropped[None])
          seg = np.vstack(cropped_seg)
  
      nonzero_mask = crop_to_bbox(nonzero_mask, bbox)[None]
      if seg is not None:
          seg[(seg == 0) & (nonzero_mask == 0)] = nonzero_label
      else:
          nonzero_mask = nonzero_mask.astype(int)
          nonzero_mask[nonzero_mask == 0] = nonzero_label
          nonzero_mask[nonzero_mask > 0] = 0
          seg = nonzero_mask
      return data, seg, bbox
  
imports: import os
  import json
  import shutil
  import pickle
  import numpy
  import SimpleITK
  from scipy.ndimage import binary_fill_holes
  from multiprocessing import Pool
  from collections import OrderedDict
  from .path_utils import join_paths
label_desc: Use image node_id 9 for calling a global function with example usage: crop_to_nonzero(data, seg, nonzero_label) and returns: data,  seg,  bbox