code: def _batch_gather(x, inds):
      assert x.dim() == 3
      batch_size = x.size(0)
      length = x.size(1)
      dim = x.size(2)
      x_flat = x.view(batch_size * length, dim)
  
      batch_offsets = (
          torch.arange(batch_size, device=inds.device) * length
      )
      batch_offsets = batch_offsets.unsqueeze(-1)
      assert batch_offsets.dim() == inds.dim()
      inds_flat = batch_offsets + inds
      results = F.embedding(inds_flat, x_flat)
      return results
  
imports: import functools
  import logging
  import math
  import torch
  import torch.nn.functional
  from mmf.common.registry import registry
  from mmf.models.base_model import BaseModel
  from mmf.modules.layers import ClassifierLayer
  from mmf.utils.build import build_image_encoder
  from omegaconf import OmegaConf
  from torch import nn
label_desc: Use image node_id 3 for calling a global function with example usage: _batch_gather(x, inds) and returns: results