code: def __init__(
      self, feats_in, convnet_parms, posnet_parms, transformer_parms
  ) -> None:
      super().__init__()
  
      adaptive_pool_func_map = {
          "max": AdaptiveMaxPool2d,
          "avg": AdaptiveAvgPool2d,
      }
  
      convnet_arch: List[Any] = (
          []
          if convnet_parms["dropout"][0] <= 0
          else [Dropout2d(convnet_parms["dropout"][0])]
      )
      convnet_arch.extend(
          [
              Conv2d(
                  in_channels=feats_in,
                  out_channels=convnet_parms["n_feats_out"][0],
                  kernel_size=convnet_parms["kernel_sizes"][0],
                  padding=convnet_parms["kernel_sizes"][0][0] // 2,
                  stride=convnet_parms["strides"][0],
                  groups=convnet_parms["groups"][0],
              ),
              ReLU(),
          ]
      )
      if "0" in convnet_parms["pool_layers_map"]:
          convnet_arch.append(
              MaxPool2d(
                  kernel_size=convnet_parms["pool_layers_map"]["0"]
              )
          )
      for layer_id, (
          kernel_size,
          n_in,
          n_out,
          groups,
          stride,
          dropout,
      ) in enumerate(
          zip(
              convnet_parms["kernel_sizes"][1:],
              convnet_parms["n_feats_out"][:-1],
              convnet_parms["n_feats_out"][1:],
              convnet_parms["groups"][1:],
              convnet_parms["strides"][1:],
              convnet_parms["dropout"][1:],
          )
      ):
          if dropout > 0:
              convnet_arch.append(Dropout2d(dropout))
          convnet_arch.append(
              Conv2d(
                  in_channels=n_in,
                  out_channels=n_out,
                  kernel_size=kernel_size,
                  padding=kernel_size[0] // 2,
                  stride=stride,
                  groups=groups,
              )
          )
          convnet_arch.append(ReLU())
          if str(layer_id + 1) in convnet_parms["pool_layers_map"]:
              convnet_arch.append(
                  MaxPool2d(
                      kernel_size=convnet_parms["pool_layers_map"][
                          str(layer_id + 1)
                      ]
                  )
              )
      convnet_arch.append(
          adaptive_pool_func_map[convnet_parms["adaptive_pool_func"]](
              output_size=convnet_parms["output_size"]
          )
      )
      self.conv_features = Sequential(*convnet_arch)
      conv_feat_dim = convnet_parms["n_feats_out"][-1]
      if posnet_parms is not None and transformer_parms is not None:
          self.use_transformer = True
          if posnet_parms["nonlinear"]:
              posnet_arch = [
                  Linear(2, posnet_parms["n_hidden"]),
                  ReLU(),
                  Linear(posnet_parms["n_hidden"], conv_feat_dim),
              ]
          else:
              posnet_arch = [Linear(2, conv_feat_dim)]
          self.position_features = Sequential(*posnet_arch)
          transformer_layer = TransformerEncoderLayer(
              d_model=conv_feat_dim,
              **transformer_parms["transformer_encoder_parms"],
          )
          self.transformer = TransformerEncoder(
              transformer_layer,
              num_layers=transformer_parms["n_blocks"],
          )
          # <cls> token initially set to 1/D, so it attends to all image features equally
          self.cls_token = Parameter(
              torch.ones(conv_feat_dim, 1) / conv_feat_dim
          )
          self._feat_dim = conv_feat_dim
      else:
          self.use_transformer = False
          self._feat_dim = (
              convnet_parms["output_size"][0]
              * convnet_parms["output_size"][1]
              * conv_feat_dim
          )
  
imports: import logging
  from typing import Any, Dict, List, Optional
  import torch
  import torch.nn.functional
  from torch.nn import AdaptiveAvgPool2d, AdaptiveMaxPool2d, Conv2d, Dropout2d, Linear, MaxPool2d, Parameter, ReLU, Sequential, TransformerEncoder, TransformerEncoderLayer
  import flair
  from flair.data import Image
  from flair.embeddings.base import Embeddings, register_embeddings
label_desc: Use image node_id 1 to create a new ConvTransformNetworkImageEmbeddings object from inherited base classes: ImageEmbeddings with example: obj = ConvTransformNetworkImageEmbeddings(feats_in, convnet_parms, posnet_parms, transformer_parms)