code: def drop_connect(
      inputs: torch.Tensor, p: float, training: bool
  ) -> torch.Tensor:
      """
      Drop connect layer that drops individual connections.
      Differs from dropout as dropconnect drops connections instead of whole neurons as in dropout.
  
      Based on `Deep Networks with Stochastic Depth <https://arxiv.org/pdf/1603.09382.pdf>`_.
      Adapted from `Official Tensorflow EfficientNet utils
      <https://github.com/tensorflow/tpu/blob/master/models/official/efficientnet/utils.py>`_.
  
      This function is generalized for MONAI's N-Dimensional spatial activations
      e.g. 1D activations [B, C, H], 2D activations [B, C, H, W] and 3D activations [B, C, H, W, D]
  
      Args:
          inputs: input tensor with [B, C, dim_1, dim_2, ..., dim_N] where N=spatial_dims.
          p: probability to use for dropping connections.
          training: whether in training or evaluation mode.
  
      Returns:
          output: output tensor after applying drop connection.
      """
      if p < 0.0 or p > 1.0:
          raise ValueError(f"p must be in range of [0, 1], found {p}")
  
      # eval mode: drop_connect is switched off - so return input without modifying
      if not training:
          return inputs
  
      # train mode: calculate and apply drop_connect
      batch_size: int = inputs.shape[0]
      keep_prob: float = 1 - p
      num_dims: int = len(inputs.shape) - 2
  
      # build dimensions for random tensor, use num_dims to populate appropriate spatial dims
      random_tensor_shape: list[int] = [batch_size, 1] + [1] * num_dims
  
      # generate binary_tensor mask according to probability (p for 0, 1-p for 1)
      random_tensor: torch.Tensor = torch.rand(
          random_tensor_shape, dtype=inputs.dtype, device=inputs.device
      )
      random_tensor += keep_prob
  
      # round to form binary tensor
      binary_tensor: torch.Tensor = torch.floor(random_tensor)
  
      # drop connect using binary tensor
      output: torch.Tensor = inputs / keep_prob * binary_tensor
      return output
  
imports: from __future__ import annotations
  import math
  import operator
  import re
  from functools import reduce
  from typing import NamedTuple
  import torch
  from torch import nn
  from torch.utils import model_zoo
  from monai.networks.blocks import BaseEncoder
  from monai.networks.layers.factories import Act, Conv, Pad, Pool
  from monai.networks.layers.utils import get_norm_layer
  from monai.utils.module import look_up_option
label_desc: Use image node_id 2 for calling a global function with example usage: drop_connect(inputs, p, training) and returns: output, inputs