code: def _validate_generator_model(
      generator: GeneratorType, conditional: bool = False
  ) -> None:
      """Validate that the user provided generator has the right methods and attributes.
  
      Args:
          generator: Generator model
          conditional: Whether the generator is conditional or not (i.e. whether it takes labels as input).
  
      """
      if not hasattr(generator, "sample"):
          raise NotImplementedError(
              "The generator must have a `sample` method with signature `sample(num_samples: int) -> Tensor` where the"
              " returned tensor has shape `(num_samples, z_size)`."
          )
      if not callable(generator.sample):
          raise ValueError(
              "The generator's `sample` method must be callable."
          )
      if conditional and not hasattr(generator, "num_classes"):
          raise AttributeError(
              "The generator must have a `num_classes` attribute when `conditional=True`."
          )
      if conditional and not isinstance(generator.num_classes, int):
          raise ValueError(
              "The generator's `num_classes` attribute must be an integer when `conditional=True`."
          )
  
file_path: torchmetrics/src/torchmetrics/functional/image/perceptual_path_length.py
imports: import math
  from typing import Literal, Optional, Tuple, Union
  import torch
  from torch import Tensor, nn
  from torchmetrics.functional.image.lpips import _LPIPS
  from torchmetrics.utilities.imports import _TORCHVISION_AVAILABLE
label_desc: Use image node_id 1 for calling a global function with example usage: _validate_generator_model(generator, conditional) without return types