code: def mask_select(src: Tensor, dim: int, mask: Tensor) -> Tensor:
      r"""Returns a new tensor which masks the :obj:`src` tensor along the
      dimension :obj:`dim` according to the boolean mask :obj:`mask`.
  
      Args:
          src (torch.Tensor): The input tensor.
          dim (int): The dimension in which to mask.
          mask (torch.BoolTensor): The 1-D tensor containing the binary mask to
              index with.
      """
      assert mask.dim() == 1
  
      if not torch.jit.is_scripting():
          if isinstance(src, TensorFrame):
              assert dim == 0 and src.num_rows == mask.numel()
              return src[mask]
  
      assert src.size(dim) == mask.numel()
      dim = dim + src.dim() if dim < 0 else dim
      assert dim >= 0 and dim < src.dim()
  
      # Applying a 1-dimensional mask in the first dimension is significantly
      # faster than broadcasting the mask and utilizing `masked_select`.
      # As such, we transpose in the first dimension, perform the masking, and
      # then transpose back to the original shape.
      src = src.transpose(0, dim) if dim != 0 else src
      out = src[mask]
      out = out.transpose(0, dim) if dim != 0 else out
  
      return out
  
imports: from typing import Optional
  import torch
  from torch import Tensor
  from torch_geometric.typing import TensorFrame
label_desc: Use image node_id 1 for calling a global function with example usage: mask_select(src, dim, mask) and returns: out, src