code: def should_regularize(regularize_layers):
      regularize = False
      if isinstance(regularize_layers, bool) and regularize_layers:
          regularize = True
      elif (
          isinstance(regularize_layers, (list, tuple))
          and regularize_layers
          and regularize_layers[-1]
      ):
          regularize = True
      return regularize
  
imports: import re
  from typing import Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from ludwig.constants import NAME, PREPROCESSING, SEQUENCE, TEXT, TIMESERIES, TYPE
  from ludwig.utils.data_utils import hash_dict
  from ludwig.utils.strings_utils import get_tokenizer_from_registry, UNKNOWN_SYMBOL
label_desc: Use image node_id 1 for calling a global function with example usage: should_regularize(regularize_layers) and returns: regularize