class_docstr: Transformer Encoder.
  
  Attributes:
    num_layers: Number of layers.
    mlp_dim: Dimension of the mlp on top of attention block.
    inputs_positions: Input subsequence positions for packed examples.
    dropout_rate: Dropout rate.
    stochastic_depth: probability of dropping a layer linearly grows
      from 0 to the provided value. Our implementation of stochastic depth
      follows timm library, which does per-example layer dropping and uses
      independent dropping patterns for each skip-connection.
    dtype: Dtype of activations.
code: def get_sd_coef(self, sd_str, lyr):
      mean_of_all_layers = np.mean(
          [
              x / max(self.num_layers - 1, 1)
              for x in range(self.num_layers)
          ]
      )
      if sd_str == "drop_flat":
          sd_coef = mean_of_all_layers
      elif sd_str == "drop_late":
          sd_coef = lyr / max(self.num_layers - 1, 1)
      elif sd_str == "drop_early":
          sd_coef = max(self.num_layers - 1 - lyr, 0) / max(
              self.num_layers - 1, 1
          )
      else:
          raise NotImplementedError(
              "not implemented sd_direction %s" % sd_str
          )
      return sd_coef
  
imports: from typing import Any, Callable, Optional, Sequence
  from absl import logging
  import flax
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.model_lib.base_models.multilabel_classification_model import MultiLabelClassificationModel
  from scenic.model_lib.layers import attention_layers
  from scenic.model_lib.layers import nn_layers
  import scipy
label_desc: Use image node_id 1 for calling the Encoder obj's underlying member method code with example usage: obj.get_sd_coef(sd_str, lyr) and returns: sd_coef