code: def __init__(
      self,
      config: XGLMConfig,
      embed_tokens: Optional[TFSharedEmbeddings] = None,
      *inputs,
      **kwargs: Any,
  ) -> None:
      super().__init__(*inputs, **kwargs)
  
      self.config = config
      self.padding_idx = config.pad_token_id
      self.max_target_positions = config.max_position_embeddings
      self.embed_scale = (
          math.sqrt(config.d_model) if config.scale_embedding else 1.0
      )
  
      if embed_tokens is not None:
          self.embed_tokens = embed_tokens
      else:
          self.embed_tokens = TFSharedEmbeddings(
              config.vocab_size,
              config.d_model,
              self.padding_idx,
              name="embed_tokens",
          )
  
      self.offset = 2
      self._embed_positions_weights = create_sinusiodal_positions(
          num_positions=config.max_position_embeddings + self.offset,
          embedding_dim=config.d_model,
          padding_idx=config.pad_token_id,
      )
  
      self.dropout = tf.keras.layers.Dropout(config.dropout)
      self.layers = [
          TFXGLMDecoderLayer(config, name=f"layers.{i}")
          for i in range(config.num_layers)
      ]
      self.layerdrop = config.layerdrop
      self.layer_norm = tf.keras.layers.LayerNormalization(
          epsilon=1e-5, name="layer_norm"
      )
  
imports: import math
  import random
  from typing import Any, Optional, Tuple, Union
  import numpy
  import tensorflow
  from ...activations_tf import get_tf_activation
  from ...file_utils import DUMMY_INPUTS, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, replace_return_docstrings
  from ...modeling_tf_outputs import TFBaseModelOutputWithPastAndCrossAttentions, TFCausalLMOutputWithCrossAttentions
  from ...modeling_tf_utils import TFCausalLanguageModelingLoss, TFModelInputType, TFPreTrainedModel, TFSharedEmbeddings, get_initializer, keras_serializable, unpack_inputs
  from ...tf_utils import shape_list, stable_softmax
  from ...utils import logging
  from .configuration_xglm import XGLMConfig
label_desc: Use image node_id 1 to create a new TFXGLMMainLayer object from inherited base classes: tf.keras.layers with example: obj = TFXGLMMainLayer(config, embed_tokens)