code: def sample_lengths(
      num_rays: int,
      num_ray_points: int,
      device: Device,
      dtype: torch.dtype,
      irregular: bool = False,
  ) -> Tensor:
      if num_ray_points <= 1:
          raise ValueError(
              "Number of ray points must be greater than 1"
          )
      if not irregular:
          zero_to_one = torch.linspace(
              0.0, 1.0, num_ray_points, device=device, dtype=dtype
          )
          lengths = zero_to_one.repeat(
              num_rays, 1
          )  # FIXME: Expand instead of repeat maybe?
      else:
          zero_to_one = torch.linspace(
              0.0, 1.0, num_ray_points + 1, device=device, dtype=dtype
          )
          lengths = (
              torch.rand(num_rays, num_ray_points, device=device)
              / num_ray_points
              + zero_to_one[:-1]
          )
      return lengths
  
imports: import math
  from typing import Dict, List, Tuple
  import torch
  from kornia.core import Device, Tensor, tensor
  from kornia.geometry.camera import PinholeCamera
  from kornia.nerf.camera_utils import cameras_for_ids
  from kornia.utils._compat import torch_meshgrid
  from kornia.utils.helpers import _torch_inverse_cast
label_desc: Use image node_id 1 for calling a global function with example usage: sample_lengths(num_rays, num_ray_points, device, dtype, irregular) and returns: lengths