code: def expand_var(name, item, n_expected, reference):
      """Expand a variable to an expected length.
  
      This is used to handle arguments to primitives that can all be reasonably
      set to the same value, or multiple different values.
  
      Args:
          name (str): Name of variable being expanded.
          item (any): Element being expanded.
          n_expected (int): Number of elements expected.
          reference (str): Source of n_expected.
  
      Returns:
          list: List of references to item or item itself.
  
      Raises:
          ValueError: If the variable is a sequence but length of the variable
              is not 1 or n_expected.
  
      """
      if n_expected == 1:
          warnings.warn(
              f"Providing a {reference} of length 1 prevents {name} from "
              f"being expanded."
          )
      if isinstance(item, (list, tuple)):
          if len(item) == n_expected:
              return item
          elif len(item) == 1:
              return list(item) * n_expected
          else:
              raise ValueError(
                  f"{name} is length {len(item)} but should be length "
                  f"{n_expected} to match {reference}"
              )
      else:
          return [item] * n_expected
  
imports: import copy
  import math
  import warnings
  import torch
  from torch import nn
  import torch.nn.functional
label_desc: Use image node_id 21 for calling a global function with example usage: expand_var(name, item, n_expected, reference) and returns: unknown, item, unknown