docstr: Generate captions for given image features using greedy search.
docstr_tok: ["Generate","captions","for","given","image","features","using","greedy","search","."]
code: def sample(self, features, states=None):
      """Generate captions for given image features using greedy search."""
      sampled_ids = []
      inputs = features.unsqueeze(1)
      for i in range(self.max_seg_length):
          hiddens, states = self.lstm(
              inputs, states
          )  # hiddens: (batch_size, 1, hidden_size)
          outputs = self.linear(
              hiddens.squeeze(1)
          )  # outputs:  (batch_size, vocab_size)
          _, predicted = outputs.max(1)  # predicted: (batch_size)
          sampled_ids.append(predicted)
          inputs = self.embed(
              predicted
          )  # inputs: (batch_size, embed_size)
          inputs = inputs.unsqueeze(
              1
          )  # inputs: (batch_size, 1, embed_size)
      sampled_ids = torch.stack(
          sampled_ids, 1
      )  # sampled_ids: (batch_size, max_seq_length)
      return sampled_ids
  
file_path: pytorch-tutorial/tutorials/03-advanced/image_captioning/model.py
imports: import torch
  import torch.nn
  import torchvision.models
  from torch.nn.utils.rnn import pack_padded_sequence
label_desc: Use image node_id 3 for calling the DecoderRNN obj's underlying member method code with example usage: obj.sample(features, states) and returns: sampled_ids