docstr: Helper function which defines starting sequence to begin generating
  with and maximum allowed number of tokens to be generated.
docstr_tok: ["Helper","function","which","defines","starting","sequence","to","begin","generating","with","and","maximum","allowed","number","of","tokens","to","be","generated","."]
code: def _prepare_for_search(
      self, decoder_input_ids=None, encoder_hidden_states=None
  ):
      """
      Helper function which defines starting sequence to begin generating
      with and maximum allowed number of tokens to be generated.
      """
  
      decoder_parameter = next(self.decoders[0].parameters())
      batch_size = self.batch_size
  
      # for encoder-decoder generation, maximum length of generated sequence
      # is min(max_sequence_length, src_len + max_delta_length)
      if encoder_hidden_states is not None:
          batch_size, src_len, _ = encoder_hidden_states.size()
          if self.max_delta_len >= 0:
              max_seq_length = min(
                  self.max_seq_length, src_len + self.max_delta_len
              )
          else:
              max_seq_length = self.max_seq_length
      else:
          max_seq_length = self.max_seq_length
  
      # if no input is provided, start with the batch of <bos> tokens
      if decoder_input_ids is not None:
          tgt = decoder_input_ids
          batch_size, tgt_len = decoder_input_ids.size()
      else:
          tgt = (
              torch.zeros(batch_size, 1)
              .long()
              .fill_(self.bos)
              .to(decoder_parameter.device)
          )
          tgt_len = 1
      max_generation_length = max_seq_length - tgt_len
  
      return tgt, batch_size, max_generation_length
  
imports: from contextlib import contextmanager
  import torch
  from nemo.collections.common.parts import NEG_INF, mask_padded_tokens
label_desc: Use image node_id 5 for calling the EnsembleBeamSearchSequenceGenerator obj's underlying member method code with example usage: obj._prepare_for_search(decoder_input_ids, encoder_hidden_states) and returns: tgt,  batch_size,  max_generation_length