code: def np_shifted_crop(v, idx_grid, shift, crop_size, ntarget):
      """Create a shifted crop."""
      nchannel = v.shape[1]
      vxyz = v[:, :3] - shift * crop_size * 0.5
      vall = v.copy()
      point_idxs = np.arange(v.shape[0])
      point_grid_idx = np.floor(vxyz / crop_size).astype(np.int32)
      valid_mask = np.ones(point_grid_idx.shape[0]).astype(bool)
      for i in range(3):
          valid_mask = np.logical_and(
              valid_mask, point_grid_idx[:, i] >= 0
          )
          valid_mask = np.logical_and(
              valid_mask, point_grid_idx[:, i] < idx_grid.shape[i]
          )
      point_grid_idx = point_grid_idx[valid_mask]
      # translate to global grid index
      point_grid_idx = np_gather_ijk_index(idx_grid, point_grid_idx)
  
      vall = vall[valid_mask]
      point_idxs = point_idxs[valid_mask]
      crop_indices, revidx = np.unique(
          point_grid_idx, axis=0, return_inverse=True
      )
      ncrops = crop_indices.shape[0]
      sortarr = np.argsort(revidx)
      revidx_sorted = revidx[sortarr]
      vall_sorted = vall[sortarr]
      point_idxs_sorted = point_idxs[sortarr]
      bins = np.searchsorted(revidx_sorted, np.arange(ncrops))
      bins = list(bins) + [v.shape[0]]
      sid = bins[0:-1]
      eid = bins[1:]
      # initialize outputs
      point_crops = np.zeros([ncrops, ntarget, nchannel])
      crop_point_idxs = []
      # extract crops and pad
      for i, (s, e) in enumerate(zip(sid, eid)):
          cropped_points = vall_sorted[s:e]
          crop_point_idx = point_idxs_sorted[s:e]
          crop_point_idxs.append(crop_point_idx)
          if cropped_points.shape[0] < ntarget:
              padded_points = np_pad_points(
                  cropped_points, ntarget=ntarget
              )
          else:
              choice_idx = np.random.choice(
                  cropped_points.shape[0], ntarget, replace=False
              )
              padded_points = cropped_points[choice_idx]
          point_crops[i] = padded_points
      return point_crops, crop_indices, crop_point_idxs
  
file_path: graphics/tensorflow_graphics/projects/local_implicit_grid/core/point_utils.py
imports: import numpy
  from plyfile import PlyData
  from plyfile import PlyElement
label_desc: Use image node_id 5 for calling a global function with example usage: np_shifted_crop(v, idx_grid, shift, crop_size, ntarget) and returns: point_crops,  crop_indices,  crop_point_idxs