code: def sequence_length_2D(sequence: torch.Tensor) -> torch.Tensor:
      """Returns the number of non-padding elements per sequence in batch.
  
      :param sequence: (torch.Tensor) A 2D tensor of shape [batch size x max sequence length].
  
      # Return
      :returns: (torch.Tensor) The count on non-zero elements per sequence.
      """
      used = (sequence != SpecialSymbol.PADDING.value).type(torch.int32)
      length = torch.sum(used, 1)
      return length
  
imports: import math
  import os
  import warnings
  from abc import abstractmethod
  from functools import lru_cache
  from typing import List, Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.nn import Module, ModuleDict
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.constants import ENCODER_OUTPUT
  from ludwig.utils.strings_utils import SpecialSymbol
label_desc: Use image node_id 3 for calling a global function with example usage: sequence_length_2D(sequence) and returns: length