def torchcrop(x, start_idx, crop_sz):
    """
    Arguments
    ---------
    x : Tensor to be cropped
        Either of dim 2 or of 3
    start_idx: tuple/list
        Start indices to crop from in each axis
    crop_sz: tuple/list
        Crop size

    Returns
    -------
    cropped tensor
    """
    dim = len(x.shape) # numpy has .ndim while torch only has dim()!
    assert dim >= 1 and dim <=3, 'supported dimensions: 1, 2 and 3 only'
    if dim == 1:
        return x[start_idx[0]:start_idx[0]+crop_sz[0]]
    elif dim == 2:
        return x[start_idx[0]:start_idx[0]+crop_sz[0],
                 start_idx[1]:start_idx[1]+crop_sz[1]]
    else:
        return x[start_idx[0]:start_idx[0]+crop_sz[0],
                 start_idx[1]:start_idx[1]+crop_sz[1],
                 start_idx[2]:start_idx[2]+crop_sz[2]]