class_docstr: Class to allow subclasses wrapped in @dataclass to automatically
  cast fields to their relevant type by default.
  
  Also allows for an arbitrary intialization function to be applied
  for a given field.
class_docstr_tok: ["Class","to","allow","subclasses","wrapped","in","@","dataclass","to","automatically","cast","fields","to","their","relevant","type","by","default",".","Also","allows","for","an","arbitrary","intialization","function","to","be","applied","for","a","given","field","."]
code: def __post_init__(self) -> None:
      f"""
          This function is run by the dataclass library after '__init__'.
  
          Here we use this to ensure all fields are casted to their declared types
          and to apply any complex field_initializer functions that have been
          declared via the 'complex_initialized_dataclass_field' method of
          this class.
  
          A complex field_initializer for a given field would be stored in the
          field.metadata dictionary at:
              key = '{self.COMPLEX_INITIALIZER}' (self.COMPLEX_INITIALIZER)
  
          """
      for field in dataclass_fields(self):
          value = getattr(self, field.name)
          # First check if the datafield has been set to the declared type or
          # if the datafield has a declared complex field_initializer.
          if (
              not isinstance(value, field.type)
              or DataclassFieldCaster.COMPLEX_INITIALIZER
              in field.metadata
          ):
              # Apply the complex field_initializer function for this field's value,
              # assert that the resultant type is the declared type of the field.
              if (
                  DataclassFieldCaster.COMPLEX_INITIALIZER
                  in field.metadata
              ):
                  setattr(
                      self,
                      field.name,
                      field.metadata[
                          DataclassFieldCaster.COMPLEX_INITIALIZER
                      ](value),
                  )
                  assert isinstance(
                      getattr(self, field.name), field.type
                  ), (
                      f"'field_initializer' function of {field.name} must return "
                      f"type {field.type} but returned type {type(getattr(self, field.name))}"
                  )
              else:
                  # Otherwise attempt to cast the field's value to its declared type.
                  setattr(self, field.name, field.type(value))
  
imports: from __future__ import annotations
  import csv
  import itertools
  import logging
  import math
  import sys
  import threading
  from collections import defaultdict
  from dataclasses import Field, field, fields
  from fractions import Fraction
  from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union
  import av
  import numpy
  import torch
  from iopath.common.file_io import g_pathmgr
label_desc: Use image node_id 1 for calling the DataclassFieldCaster obj's underlying member method code with example usage: obj.__post_init__() without return types