code: def _select_lmc_coefficients(
      lmc_coefficients: torch.Tensor, indices: torch.LongTensor
  ) -> torch.Tensor:
      """
      Given a list of indices for ... x N datapoints,
        select the row from lmc_coefficient that corresponds to each datapoint
  
      lmc_coefficients: torch.Tensor ... x num_latents x ... x num_tasks
      indices: torch.Tesnor ... x N
      """
      batch_shape = torch.broadcast_shapes(
          lmc_coefficients.shape[:-1], indices.shape[:-1]
      )
  
      # We will use the left_interp helper to do the indexing
      lmc_coefficients = lmc_coefficients.expand(
          *batch_shape, lmc_coefficients.shape[-1]
      )[..., None]
      indices = indices.expand(*batch_shape, indices.shape[-1])[
          ..., None
      ]
      res = left_interp(
          indices,
          torch.ones(
              indices.shape, dtype=torch.long, device=indices.device
          ),
          lmc_coefficients,
      ).squeeze(-1)
      return res
  
file_path: gpytorch/gpytorch/variational/lmc_variational_strategy.py
imports: from typing import Optional, Union
  import torch
  from linear_operator.operators import KroneckerProductLinearOperator, RootLinearOperator
  from linear_operator.utils.interpolation import left_interp
  from torch import LongTensor, Tensor
  from ..None import settings
  from ..distributions import MultitaskMultivariateNormal, MultivariateNormal
  from ..module import Module
  from ._variational_strategy import _VariationalStrategy
label_desc: Use image node_id 1 for calling a global function with example usage: _select_lmc_coefficients(lmc_coefficients, indices) and returns: res