code: def set_classy_state(self, state, strict=True):
      # We need to support both regular checkpoint loading and 2D conv weight
      # inflation into 3D conv weight in this function.
      self.load_head_states(state)
  
      # clear the heads to set the trunk state
      attached_heads = self.get_heads()
      self.clear_heads()
  
      current_state = self.state_dict()
      for name, weight_src in state["model"]["trunk"].items():
          if name not in current_state:
              logging.warning(
                  f"weight {name} is not found in current ResNeXt3D state"
              )
              continue
  
          weight_tgt = current_state[name]
          assert (
              weight_src.dim() == weight_tgt.dim()
          ), "weight of source- and target 3D convolution should have same dimension"
          if (
              weight_src.dim() == 5
              and weight_src.shape[2] == 1
              and weight_tgt.shape[2] > 1
          ):
              # Find a source weight tensor where temporal dimension is 1. If the
              # temporal dimension of the current weight tensor with the same name
              # is larger than 1, we inflate the source weight tensor before
              # loading it. Such parameter inflation was first introduced in
              # the paper (https://arxiv.org/abs/1705.07750). It can achieve a
              # better initialization compared to random initialization.
              assert (
                  weight_src.shape[-2:] == weight_tgt.shape[-2:]
                  and weight_src.shape[:2] == weight_tgt.shape[:2]
              ), "weight shapes of source- and target 3D convolution mismatch"
              weight_src_inflated = (
                  weight_src.repeat(1, 1, weight_tgt.shape[2], 1, 1)
                  / weight_tgt.shape[2]
              )
              weight_src = weight_src_inflated
          else:
              assert all(
                  weight_src.size(d) == weight_tgt.size(d)
                  for d in range(weight_src.dim())
              ), (
                  "the shapes of source and target weight mismatch: %s Vs %s"
                  % (
                      str(weight_src.size()),
                      str(weight_tgt.size()),
                  )
              )
  
          current_state[name] = weight_src.clone()
      self.load_state_dict(current_state, strict=strict)
  
      # set the heads back again
      self.set_heads(attached_heads)
  
imports: import logging
  from typing import Any, Dict, Sequence
  import torch
  import torch.nn
  from classy_vision.generic.util import is_pos_int, is_pos_int_list
  from .None import register_model
  from .classy_model import ClassyModel
  from .resnext3d_stage import ResStage
  from .resnext3d_stem import R2Plus1DStem, ResNeXt3DStem
label_desc: Use image node_id 4 for calling the ResNeXt3DBase obj's underlying member method code with example usage: obj.set_classy_state(state, strict) without return types