docstr: Test Conv2plus1d.
docstr_tok: ["Test","Conv2plus1d","."]
code: def test_create_2plus1d_conv(self):
      """
      Test Conv2plus1d.
      """
      for input_dim, output_dim in itertools.product(
          (2, 4), (4, 8, 16)
      ):
          model = Conv2plus1d(
              conv_t=nn.Conv3d(
                  in_channels=input_dim,
                  out_channels=output_dim,
                  kernel_size=(3, 1, 1),
                  stride=(2, 1, 1),
                  padding=(1, 0, 0),
                  bias=False,
              ),
              norm=nn.BatchNorm3d(output_dim),
              activation=nn.ReLU(),
              conv_xy=nn.Conv3d(
                  in_channels=output_dim,
                  out_channels=output_dim,
                  kernel_size=(1, 3, 3),
                  stride=(1, 2, 2),
                  padding=(0, 1, 1),
                  bias=False,
              ),
          )
  
          model_gt = create_conv_2plus1d(
              in_channels=input_dim,
              out_channels=output_dim,
              kernel_size=(3, 3, 3),
              stride=(2, 2, 2),
              padding=(1, 1, 1),
              bias=False,
              norm=nn.BatchNorm3d,
              norm_eps=1e-5,
              norm_momentum=0.1,
              activation=nn.ReLU,
          )
  
          model.load_state_dict(
              model_gt.state_dict(), strict=True
          )  # explicitly use strict mode.
  
          # Test forwarding.
          for input_tensor in TestConv2plus1d._get_inputs():
              with torch.no_grad():
                  if input_tensor.shape[1] != input_dim:
                      with self.assertRaises(RuntimeError):
                          output_tensor = model(input_tensor)
                      continue
                  else:
                      output_tensor = model(input_tensor)
                      output_tensor_gt = model_gt(input_tensor)
              self.assertEqual(
                  output_tensor.shape,
                  output_tensor_gt.shape,
                  "Output shape {} is different from expected shape {}".format(
                      output_tensor.shape, output_tensor_gt.shape
                  ),
              )
              self.assertTrue(
                  np.allclose(
                      output_tensor.numpy(), output_tensor_gt.numpy()
                  )
              )
  
file_path: pytorchvideo/tests/test_layers_convolutions.py
imports: import itertools
  import unittest
  import numpy
  import torch
  from pytorchvideo.layers.convolutions import Conv2plus1d, ConvReduce3D, create_conv_2plus1d
  from torch import nn
label_desc: Use image node_id 2 for calling the TestConv2plus1d obj's underlying member method code with example usage: obj.test_create_2plus1d_conv() without return types