code: def test_zero_length_sequence(klass, rnn_kwargs):
      rnn = klass(input_size=2, hidden_size=5, **rnn_kwargs)
      x = torch.rand(100, 3, 2)
      lengths = torch.randint(
          0, 3, size=([3, 100][rnn_kwargs["batch_first"]],)
      )
      _, hidden_state = rnn(x, lengths=lengths, enforce_sorted=False)
      init_hidden_state = rnn.init_hidden_state(x)
  
      if isinstance(hidden_state, torch.Tensor):
          hidden_state = [hidden_state]
          init_hidden_state = [init_hidden_state]
  
      for idx in range(len(hidden_state)):
          assert (
              hidden_state[idx].size() == init_hidden_state[idx].size()
          ), "Hidden state sizes should be equal"
          assert (hidden_state[idx][:, lengths == 0] == 0).all() and (
              hidden_state[idx][:, lengths > 0] != 0
          ).all(), (
              "Hidden state should be zero for zero-length sequences"
          )
  
file_path: pytorch-forecasting/tests/test_models/test_nn/test_rnn.py
imports: import itertools
  import pytest
  import torch
  from torch import nn
  from pytorch_forecasting.models.nn.rnn import GRU, LSTM, get_rnn
label_desc: Use image node_id 4 for calling a global function with example usage: test_zero_length_sequence(klass, rnn_kwargs) without return types