code: def test_ml_embedding(self) -> None:
      def _make(embed_dims: List[int]) -> Encoder:
          nd = len(embed_dims)
          return Encoder(
              {
                  str(idx): MLEncoderSettings(
                      dim=embed_dims[idx],
                      methods="embedding",
                      method_configs={"out_dim": embed_dims[idx]},
                  )
                  for idx in range(nd)
              },
          )
  
      def _run(
          encoder: Encoder,
          net: torch.Tensor,
          repeat: int,
      ) -> Tuple[torch.Tensor, float]:
          t = time.time()
          encoded = encoder(net).embedding
          for _ in range(repeat - 1):
              encoder(net)
          return encoded, time.time() - t
  
      def _test_case(embed_dims: List[int]) -> None:
          net = torch.cat(
              [torch.randint(d, (bs, 1)) for d in embed_dims], dim=1
          )
          e = _make(embed_dims)
          r1, _ = _run(e, net, num_repeat)
          self.assertSequenceEqual(r1.shape, [bs, sum(embed_dims)])
  
      bs = 128
      num_repeat = 100
      _test_case([4] * 30)
      _test_case([4] * 10 + [8] * 10 + [16] * 10)
      for dim in [4, 64, 128, 256]:
          for n_dim in [8, 16]:
              _test_case([dim] * n_dim)
      for dim in [4, 16]:
          dims = [dim] * 16 + [dim * 2] * 12 + [dim * 3] * 8
          _test_case(dims)
  
imports: import time
  import torch
  import unittest
  import numpy
  import torch.nn
  from typing import List
  from typing import Tuple
  from cflearn.schema import MLEncoderSettings
  from cflearn.constants import LATENT_KEY
  from cflearn.misc.toolkit import eval_context
  from cflearn.misc.toolkit import inject_parameters
  from cflearn.modules.blocks import BN
  from cflearn.modules.blocks import EMA
  from cflearn.modules.blocks import DNDF
  from cflearn.modules.blocks import Conv2d
  from cflearn.modules.blocks import Linear
  from cflearn.modules.blocks import Lambda
  from cflearn.modules.blocks import Attention
  from cflearn.models.cv.encoder import BackboneEncoder
  from cflearn.models.ml.encoders import Encoder
label_desc: Use image node_id 9 for calling the TestBlocks obj's underlying member method code with example usage: obj.test_ml_embedding() and returns: Encoder, encoded,  unknown