class_docstr: Model card field base class.
  
  This is an abstract class. All the model card fields should inherit this class
  and override the _proto_type property to the corresponding proto type. This
  abstract class provides methods `from_proto`, `merge_from_proto` and
  `to_proto` to convert the class from and to proto. The child class does not
  need to override this unless it needs some special process.
docstr: Convert this class object to the proto.
docstr_tok: ["Convert","this","class","object","to","the","proto","."]
code: def to_proto(self) -> message.Message:
      """Convert this class object to the proto."""
      proto = self._proto_type()
  
      for field_name, field_value in self.__dict__.items():
          if not hasattr(proto, field_name):
              raise ValueError(
                  '%s has no such field named "%s".'
                  % (type(proto), field_name)
              )
          if not field_value:
              continue
  
          field_descriptor = proto.DESCRIPTOR.fields_by_name[field_name]
  
          # Process Message type.
          if (
              field_descriptor.type
              == descriptor.FieldDescriptor.TYPE_MESSAGE
          ):
              if (
                  field_descriptor.label
                  == descriptor.FieldDescriptor.LABEL_REPEATED
              ):
                  for nested_message in field_value:
                      getattr(proto, field_name).add().CopyFrom(
                          nested_message.to_proto()
                      )  # pylint: disable=protected-access
              else:
                  getattr(proto, field_name).CopyFrom(
                      field_value.to_proto()
                  )  # pylint: disable=protected-access
          # Process Non-Message type
          else:
              if (
                  field_descriptor.label
                  == descriptor.FieldDescriptor.LABEL_REPEATED
              ):
                  getattr(proto, field_name).extend(field_value)
              else:
                  setattr(proto, field_name, field_value)
  
      return proto
  
imports: import abc
  import dataclasses
  import json
  from textwrap import dedent
  from typing import Any, Dict, Type, TypeVar
  from warnings import warn
  from google.protobuf import descriptor, message
  from model_card_toolkit.utils import json_utils
label_desc: Use image node_id 3 for calling the BaseModelCardField obj's underlying member method code with example usage: obj.to_proto() and returns: proto