code: def _get_seq_len(src: Tensor, batch_first: bool) -> Optional[int]:
      if src.is_nested:
          return None
      else:
          src_size = src.size()
          if len(src_size) == 2:
              # unbatched: S, E
              return src_size[0]
          else:
              # batched: B, S, E if batch_first else S, B, E
              seq_len_pos = 1 if batch_first else 0
              return src_size[seq_len_pos]
  
imports: import copy
  from typing import Optional, Any, Union, Callable
  import torch
  import warnings
  from torch import Tensor
  from ..None import functional
  from .module import Module
  from .activation import MultiheadAttention
  from .container import ModuleList
  from ..init import xavier_uniform_
  from .dropout import Dropout
  from .linear import Linear
  from .normalization import LayerNorm
label_desc: Use image node_id 2 for calling a global function with example usage: _get_seq_len(src, batch_first) and returns: None, src_size, src_size