class_docstr: T5 Language model.
  
  Args:
      config (TransformerConfig): transformer config
  
      transformer_encoder_layer_spec (ModuleSpec): transformer layer customization specs for encoder
  
      transformer_decoder_layer_spec (ModuleSpec): transformer layer customization specs for decoder
              
      vocab_size (int): vocabulary size
  
      max_sequence_length (int): maximum size of sequence. This is used for positional embedding
  
      pre_process (bool): Include embedding layer (used with pipeline parallelism)
      post_process (bool): Include an output layer (used with pipeline parallelism)
  
      fp16_lm_cross_entropy (bool, optional): Defaults to False
  
      parallel_output (bool): Do not gather the outputs, keep them split across tensor parallel ranks
  
      share_embeddings_and_output_weights (bool): When True, input embeddings and output logit weights are
          shared. Defaults to False.
  
      position_embedding_type (string): Position embedding type. Options ['learned_absolute', 'rope'].
          Defaults is 'learned_absolute'.
  
      rotary_percent (float): Percent of rotary dimension to use for rotary position embeddings.
          Defaults to 1.0 (100%). Ignored unless position_embedding_type is 'rope'.
  
      seq_len_interpolation_factor (float): scale of linearly interpolating RoPE for longer sequences.
          The value must be a float larger than 1.0. Defaults to None.
class_docstr_tok: ["T5","Language","model",".","Args",":","config","(","TransformerConfig",")",":","transformer","config","transformer_encoder_layer_spec","(","ModuleSpec",")",":","transformer","layer","customization","specs","for","encoder","transformer_decoder_layer_spec","(","ModuleSpec",")",":","transformer","layer","customization","specs","for","decoder","vocab_size","(","int",")",":","vocabulary","size","max_sequence_length","(","int",")",":","maximum","size","of","sequence",".","This","is","used","for","positional","embedding","pre_process","(","bool",")",":","Include","embedding","layer","(","used","with","pipeline","parallelism",")","post_process","(","bool",")",":","Include","an","output","layer","(","used","with","pipeline","parallelism",")","fp16_lm_cross_entropy","(","bool",",","optional",")",":","Defaults","to","False","parallel_output","(","bool",")",":","Do","not","gather","the","outputs",",","keep","them","split","across","tensor","parallel","ranks","share_embeddings_and_output_weights","(","bool",")",":","When","True",",","input","embeddings","and","output","logit","weights","are","shared",".","Defaults","to","False",".","position_embedding_type","(","string",")",":","Position","embedding","type",".","Options","[","'learned_absolute","'",",","'rope","'","]",".","Defaults","is","'learned_absolute","'",".","rotary_percent","(","float",")",":","Percent","of","rotary","dimension","to","use","for","rotary","position","embeddings",".","Defaults","to","1.0","(","100","%",")",".","Ignored","unless","position_embedding_type","is","'rope","'",".","seq_len_interpolation_factor","(","float",")",":","scale","of","linearly","interpolating","RoPE","for","longer","sequences",".","The","value","must","be","a","float","larger","than","1.0",".","Defaults","to","None","."]
docstr: See megatron.model.transformer.set_input_tensor()
docstr_tok: ["See","megatron.model.transformer.set_input_tensor","(",")"]
code: def set_input_tensor(self, input_tensor):
      """See megatron.model.transformer.set_input_tensor()"""
  
      # This is usually handled in schedules.py but some inference code still
      # gives us non-lists or None
      if not isinstance(input_tensor, list):
          input_tensor = [input_tensor]
  
      if self.add_encoder and self.add_decoder:
          assert (
              len(input_tensor) == 1
          ), "input_tensor should only be length 1 for stage with both encoder and decoder"
          self.encoder.set_input_tensor(input_tensor[0])
      elif self.add_encoder:
          assert (
              len(input_tensor) == 1
          ), "input_tensor should only be length 1 for stage with only encoder"
          self.encoder.set_input_tensor(input_tensor[0])
      elif self.add_decoder:
          if len(input_tensor) == 2:
              self.decoder.set_input_tensor(input_tensor[0])
              self.encoder_hidden_state = input_tensor[1]
          elif len(input_tensor) == 1:
              self.decoder.set_input_tensor(None)
              self.encoder_hidden_state = input_tensor[0]
          else:
              raise Exception(
                  "input_tensor must have either length 1 or 2"
              )
      else:
          raise Exception(
              "Stage must have at least either encoder or decoder"
          )
  
imports: import logging
  from typing import List, Literal, Optional
  import torch
  from torch import Tensor
  from megatron.core import InferenceParams, parallel_state, tensor_parallel
  from megatron.core.models.common.embeddings.language_model_embedding import LanguageModelEmbedding
  from megatron.core.models.common.embeddings.rotary_pos_embedding import RotaryEmbedding
  from megatron.core.models.common.language_module.language_module import LanguageModule
  from megatron.core.transformer.enums import AttnMaskType, ModelType
  from megatron.core.transformer.module import MegatronModule
  from megatron.core.transformer.spec_utils import ModuleSpec
  from megatron.core.transformer.transformer_block import TransformerBlock
  from megatron.core.transformer.transformer_config import TransformerConfig
  from megatron.core.utils import make_tp_sharded_tensor_for_checkpoint
label_desc: Use image node_id 3 for calling the T5Model obj's underlying member method code with example usage: obj.set_input_tensor(input_tensor) without return types