code: def synced_generate(
      model,
      inference_strategy,
      context_tokens_tensor,
      context_length_tensor,
      tokens_to_generate,
      all_probs,
      temperature,
      top_k=0,
      top_p=0.0,
      greedy=False,
      compute_attention_mask=True,
      compute_logprob=False,
      repetition_penalty=1.2,
      end_strings=[],
      min_tokens_to_generate=0,
      image_list=None,
  ):
      context_length = context_length_tensor.min().item()
      tokenizer = model.tokenizer
      if isinstance(tokenizer, TabularTokenizer):
          batch_token_iterator = tab_sample_sequence_batch(
              model,
              inference_strategy,
              context_tokens_tensor,
              context_length_tensor,
              tokens_to_generate,
              all_probs,
              compute_attention_mask=compute_attention_mask,
              temperature=temperature,
          )
      else:
          batch_token_iterator = sample_sequence_batch(
              model,
              inference_strategy,
              context_tokens_tensor,
              context_length_tensor,
              tokens_to_generate,
              all_probs,
              compute_attention_mask=compute_attention_mask,
              compute_logprob=compute_logprob,
              temperature=temperature,
              end_strings=end_strings,
              image_list=image_list,
              extra={
                  "top_p": top_p,
                  "top_k": top_k,
                  "greedy": greedy,
                  "repetition_penalty": repetition_penalty,
                  "min_tokens_to_generate": min_tokens_to_generate,
              },
          )
  
      for (
          tokens,
          lengths,
          output_logits,
          full_logits,
      ) in batch_token_iterator:
          context_length += 1
  
      if parallel_state.is_pipeline_last_stage():
          src = parallel_state.get_pipeline_model_parallel_last_rank()
          group = parallel_state.get_embedding_group()
          if compute_logprob:
              torch.distributed.broadcast(output_logits, src, group)
          if all_probs:
              src = (
                  parallel_state.get_pipeline_model_parallel_last_rank()
              )
              group = parallel_state.get_embedding_group()
              torch.distributed.broadcast(full_logits, src, group)
  
      else:
          if parallel_state.is_pipeline_first_stage():
              src = (
                  parallel_state.get_pipeline_model_parallel_last_rank()
              )
              group = parallel_state.get_embedding_group()
  
              if compute_logprob:
                  precision = model._trainer.precision
                  dtype = torch.float32
  
                  output_logits = torch.empty(
                      tokens.size(0),
                      context_length - 1,
                      dtype=dtype,
                      device=torch.device("cuda"),
                  )
                  torch.distributed.broadcast(output_logits, src, group)
  
              if all_probs:
                  src = (
                      parallel_state.get_pipeline_model_parallel_last_rank()
                  )
                  group = parallel_state.get_embedding_group()
                  full_logits = torch.empty(
                      tokens.size(0),
                      context_length - 1,
                      model.padded_vocab_size,
                      dtype=dtype,
                      device=torch.device("cuda"),
                  )
                  torch.distributed.broadcast(full_logits, src, group)
      if tokens is not None:
          return tokens[:, :context_length], output_logits, full_logits
  
imports: import os
  import pickle
  import re
  from collections.abc import Iterable
  from functools import partial
  from typing import Callable, Tuple
  import numpy
  import torch
  import torch.nn.functional
  from nemo.collections.common.tokenizers.tabular_tokenizer import TabularTokenizer
  from nemo.collections.nlp.modules.common.megatron.utils import get_ltor_masks_and_position_ids
  from nemo.collections.nlp.modules.common.text_generation_strategy import model_inference_strategy_dispatcher
  from nemo.collections.nlp.modules.common.transformer.text_generation import LengthParam, OutputType, SamplingParam
  from nemo.utils import AppState
label_desc: Use image node_id 13 for calling a global function with example usage: synced_generate(model, inference_strategy, context_tokens_tensor, context_length_tensor, tokens_to_generate, all_probs, temperature, top_k, top_p, greedy, compute_attention_mask, compute_logprob, repetition_penalty, end_strings, min_tokens_to_generate, image_list) and returns: tokens,  output_logits,  full_logits