code: def match_dim(
      *xs: torch.Tensor, contiguous: bool = False
  ) -> Tuple[torch.Tensor, ...]:
      """match the N-1 dimensions of x and xq for searchsorted and gather with dim=-1
  
      Examples
      --------
      >>> x = torch.randn(10, 5)
      >>> xq = torch.randn(10, 3)
      >>> x_new, xq_new = match_dim(x, xq)
      >>> x_new.shape
      torch.Size([10, 5])
      >>> xq_new.shape
      torch.Size([10, 3])
  
      """
      orig_shapes = tuple(x.shape[:-1] for x in xs)
      shape = tuple(get_bcasted_dims(*orig_shapes))
      xs_new = tuple(x.expand(shape + (x.shape[-1],)) for x in xs)
      if contiguous:
          xs_new = tuple(x.contiguous() for x in xs_new)
      return xs_new
  
imports: from typing import Tuple
  import torch
label_desc: Use image node_id 3 for calling a global function with example usage: match_dim() and returns: xs_new