class_docstr: This class manages the card's state for a single card.
  - It uses the `ComponentStore` to manage the storage of the components
  - It exposes methods to add, remove and access the components.
  - It exposes a `refresh` method that will allow refreshing a card with new data
  for realtime(ish) updates.
  - The `CardComponentCollector` exposes convenience methods similar to this class for a default
  editable card. These methods include :
      - `append`
      - `extend`
      - `clear`
      - `refresh`
      - `components`
      - `__iter__`
  
  ## Usage Patterns :
  
  ```python
  current.card["mycardid"].append(component, id="comp123")
  current.card["mycardid"].extend([component])
  current.card["mycardid"].refresh(data) # refreshes the card with new data
  current.card["mycardid"].components["comp123"] # returns the component with id "comp123"
  current.card["mycardid"].components["comp123"].update()
  current.card["mycardid"].components.clear() # Wipe all the components
  del current.card["mycardid"].components["mycomponentid"] # Delete a component
  ```
class_docstr_tok: ["This","class","manages","the","card","'s","state","for","a","single","card",".","-","It","uses","the","`","ComponentStore","`","to","manage","the","storage","of","the","components","-","It","exposes","methods","to","add",",","remove","and","access","the","components",".","-","It","exposes","a","`","refresh","`","method","that","will","allow","refreshing","a","card","with","new","data","for","realtime","(","ish",")","updates",".","-","The","`","CardComponentCollector","`","exposes","convenience","methods","similar","to","this","class","for","a","default","editable","card",".","These","methods","include",":","-","`","append","`","-","`","extend","`","-","`","clear","`","-","`","refresh","`","-","`","components","`","-","`","__iter__","`","#","#","Usage","Patterns",":","``","`","python","current.card","[","``","mycardid","''","]",".append","(","component",",","id=","''","comp123","''",")","current.card","[","``","mycardid","''","]",".extend","(","[","component","]",")","current.card","[","``","mycardid","''","]",".refresh","(","data",")","#","refreshes","the","card","with","new","data","current.card","[","``","mycardid","''","]",".components","[","``","comp123","''","]","#","returns","the","component","with","id","``","comp123","''","current.card","[","``","mycardid","''","]",".components","[","``","comp123","''","]",".update","(",")","current.card","[","``","mycardid","''","]",".components.clear","(",")","#","Wipe","all","the","components","del","current.card","[","``","mycardid","''","]",".components","[","``","mycomponentid","''","]","#","Delete","a","component","``","`"]
docstr: This function returns the data object that is passed down to :
  - `MetaflowCard.render_runtime`
  - `MetaflowCard.refresh`
  - `MetaflowCard.reload_content_token`
  
  The return value of this function contains all the necessary state information for Metaflow Cards to make decisions on the following:
  1. What components are rendered
  2. Should the card be reloaded on the UI
  3. What data to pass down to the card.
  
  Parameters
  ----------
  final : bool, optional
      If True, it implies that the final "rendering" sequence is taking place (which involves calling a `render` and a `refresh` function.)
      When final is set the `render_seq` is set to "final" so that the reload token in the card is set to final
      and the card is not reloaded again on the user interface.
  mode : str
      This parameter is passed down to the object returned by this function. Can be one of `render_runtime` / `refresh` / `render`
  
  Returns
  -------
  dict
      A dictionary of the form :
      ```python
      {
          "user": user_data, # any passed to `current.card.refresh` function
          "components": component_dict, # all rendered REALTIME_UPDATABLE components
          "render_seq": seq,
          # `render_seq` is a counter that is incremented every time `render_runtime` is called.
          # If a metaflow card has a RELOAD_POLICY_ALWAYS set then the reload token will be set to this value
          # so that the card reload on the UI everytime `render_runtime` is called.
          "component_update_ts": self.components.layout_last_changed_on,
          # `component_update_ts` is the timestamp of the last time the component array was modified.
          # `component_update_ts` can get used by the `reload_content_token` to make decisions on weather to
          # reload the card on the UI when component array has changed.
          "mode": mode,
      }
      ```
docstr_tok: ["This","function","returns","the","data","object","that","is","passed","down","to",":","-","`","MetaflowCard.render_runtime","`","-","`","MetaflowCard.refresh","`","-","`","MetaflowCard.reload_content_token","`","The","return","value","of","this","function","contains","all","the","necessary","state","information","for","Metaflow","Cards","to","make","decisions","on","the","following",":","1",".","What","components","are","rendered","2",".","Should","the","card","be","reloaded","on","the","UI","3",".","What","data","to","pass","down","to","the","card",".","Parameters","--","--","--","--","--","final",":","bool",",","optional","If","True",",","it","implies","that","the","final","``","rendering","''","sequence","is","taking","place","(","which","involves","calling","a","`","render","`","and","a","`","refresh","`","function",".",")","When","final","is","set","the","`","render_seq","`","is","set","to","``","final","''","so","that","the","reload","token","in","the","card","is","set","to","final","and","the","card","is","not","reloaded","again","on","the","user","interface",".","mode",":","str","This","parameter","is","passed","down","to","the","object","returned","by","this","function",".","Can","be","one","of","`","render_runtime","`","\/","`","refresh","`","\/","`","render","`","Returns","--","--","--","-","dict","A","dictionary","of","the","form",":","``","`","python","{","``","user","''",":","user_data",",","#","any","passed","to","`","current.card.refresh","`","function","``","components","''",":","component_dict",",","#","all","rendered","REALTIME_UPDATABLE","components","``","render_seq","''",":","seq",",","#","`","render_seq","`","is","a","counter","that","is","incremented","every","time","`","render_runtime","`","is","called",".","#","If","a","metaflow","card","has","a","RELOAD_POLICY_ALWAYS","set","then","the","reload","token","will","be","set","to","this","value","#","so","that","the","card","reload","on","the","UI","everytime","`","render_runtime","`","is","called",".","``","component_update_ts","''",":","self.components.layout_last_changed_on",",","#","`","component_update_ts","`","is","the","timestamp","of","the","last","time","the","component","array","was","modified",".","#","`","component_update_ts","`","can","get","used","by","the","`","reload_content_token","`","to","make","decisions","on","weather","to","#","reload","the","card","on","the","UI","when","component","array","has","changed",".","``","mode","''",":","mode",",","}","``","`"]
code: def _get_latest_data(self, final=False, mode=None):
      """
      This function returns the data object that is passed down to :
      - `MetaflowCard.render_runtime`
      - `MetaflowCard.refresh`
      - `MetaflowCard.reload_content_token`
  
      The return value of this function contains all the necessary state information for Metaflow Cards to make decisions on the following:
      1. What components are rendered
      2. Should the card be reloaded on the UI
      3. What data to pass down to the card.
  
      Parameters
      ----------
      final : bool, optional
          If True, it implies that the final "rendering" sequence is taking place (which involves calling a `render` and a `refresh` function.)
          When final is set the `render_seq` is set to "final" so that the reload token in the card is set to final
          and the card is not reloaded again on the user interface.
      mode : str
          This parameter is passed down to the object returned by this function. Can be one of `render_runtime` / `refresh` / `render`
  
      Returns
      -------
      dict
          A dictionary of the form :
          ```python
          {
              "user": user_data, # any passed to `current.card.refresh` function
              "components": component_dict, # all rendered REALTIME_UPDATABLE components
              "render_seq": seq,
              # `render_seq` is a counter that is incremented every time `render_runtime` is called.
              # If a metaflow card has a RELOAD_POLICY_ALWAYS set then the reload token will be set to this value
              # so that the card reload on the UI everytime `render_runtime` is called.
              "component_update_ts": self.components.layout_last_changed_on,
              # `component_update_ts` is the timestamp of the last time the component array was modified.
              # `component_update_ts` can get used by the `reload_content_token` to make decisions on weather to
              # reload the card on the UI when component array has changed.
              "mode": mode,
          }
          ```
      """
      seq = "final" if final else self._render_seq
      # Extract all the runtime-updatable components as a dictionary
      component_dict = {}
      for (
          component
      ) in self._components._realtime_updateable_components():
          rendered_comp = _render_card_component(component)
          if rendered_comp is not None:
              component_dict.update(
                  {component.component_id: rendered_comp}
              )
  
      # Verify _latest_user_data is json serializable
      user_data = {}
      if (
          self._latest_user_data is not None
          and not _object_is_json_serializable(self._latest_user_data)
      ):
          self._warning(
              "Data provided to `refresh` is not JSON serializable. It will be ignored."
          )
      else:
          user_data = self._latest_user_data
  
      return {
          "user": user_data,
          "components": component_dict,
          "render_seq": seq,
          "component_update_ts": self.components.layout_last_changed_on,
          "mode": mode,
      }
  
imports: from .card_modules import MetaflowCardComponent
  from .card_modules.basic import ErrorComponent, SectionComponent
  from .card_modules.components import UserComponent, create_component_id, StubComponent
  from .exception import ComponentOverwriteNotSupportedException
  from metaflow.metaflow_config import RUNTIME_CARD_RENDER_INTERVAL
  import uuid
  import json
  import platform
  from collections import OrderedDict
  import time
label_desc: Use image node_id 9 for calling the CardComponentManager obj's underlying member method code with example usage: obj._get_latest_data(final, mode) and returns: dict